Commit Graph
49 Commits
Author SHA1 Message Date
Asger Hautop DrewsenandDavid Pedersen 40da647620 docs: Remove explicit auto deref from PrivateCookieJar example (#2028)
Co-authored-by: David Pedersen <[email protected]>
2023-06-22 21:50:45 +00:00
Azzam S.A 8374c3e789 docs: add warning icon for extractor order (#2027) 2023-06-05 12:05:53 +02:00
877e3fe4de Move TypedHeader to axum-extra (#1850)
Co-authored-by: Michael Scofield <[email protected]>
Co-authored-by: Jonas Platte <[email protected]>
2023-04-21 17:45:31 +02:00
David Pedersen c97967252d Add serve function and remove Server re-export (#1868) 2023-04-21 17:45:31 +02:00
6703f8634c Remove B type param: Follow ups (#1789)
Co-authored-by: Jonas Platte <[email protected]>
Co-authored-by: Michael Scofield <[email protected]>
2023-04-21 17:45:31 +02:00
David Pedersen 72c1b7a80c Add Body::from_stream (#1848) 2023-04-21 17:45:31 +02:00
4e4c29175f Remove B type param (#1751)
Co-authored-by: Jonas Platte <[email protected]>
Co-authored-by: Michael Scofield <[email protected]>
2023-04-21 17:45:31 +02:00
David Pedersen 6b106f4bab Log built-in rejections (#1890) 2023-04-11 16:57:49 +02:00
David Pedersen 352cf9a266 Implement Deref and DerefMut for built-in extractors (#1922) 2023-04-10 07:18:35 +00:00
Jonas PlatteandDavid Pedersen 43b2d52403 Add OptionalPath extractor (#1889)
Co-authored-by: David Pedersen <[email protected]>
2023-04-09 12:23:13 +00:00
David Pedersen 03e8bc77f1 Implement IntoResponse for MultipartError (#1861) 2023-03-21 08:24:06 +00:00
Dan Handrea e167cfc325 Implement Clone for CookieJar, PrivateCookieJar and SignedCookieJar (#1808) 2023-03-03 11:13:25 +00:00
David Pedersen aa2cbf6920 Add axum_extra::extract::Multipart (#1692) 2023-03-03 10:15:09 +01:00
Rob 68bf8ed7fc Update documentation for FailedToDeserializeQueryString response type (#1795) 2023-02-27 22:29:39 +00:00
avdb ea6eb81d6f Typo fixes (#1628) 2022-12-08 17:50:59 +00:00
David Pedersen 0b26411f39 Change Router::with_state and impl Service for Router<()> (#1552)
* Implement `Service` for `Router<(), B>`

* wip

* wip

* fix some tests

* fix examples

* fix doc tests

* clean up docs

* changelog

* fix

* also call `with_state` when converting `MethodRouter` into a `MakeService`

* suggestions from review
2022-11-24 14:43:10 +00:00
walfie 7d0bb28876 Minor doc fixes (#1562) 2022-11-22 07:08:18 +00:00
Santiago Fraire Willemoes ddee1c1d1a docs: add how to use Arc<AppState> with the cookies examples (#1560) 2022-11-21 14:17:32 +01:00
David Pedersen 64960bb19c Type safe state inheritance (#1532)
* Make state type safe

* fix examples

* remove unnecessary `#[track_caller]`s

* Router::into_service -> Router::with_state

* fixup docs

* macro docs

* add missing docs

* fix examples

* format

* changelog

* Update trybuild tests

* Make sure fallbacks are still inherited for opaque services (#1540)

* Document nesting routers with different state

* fix leftover conflicts
2022-11-18 11:02:58 +00:00
David Pedersen e0ef641e5f Rework Form and Query rejections (#1496)
* Change `FailedToDeserializeQueryString` rejection for `Form`

Its now called `FailedToDeserializeForm`.

* changelog

* Make dedicate rejection type for axum-extra's `Form`

* update trybuild test

* Make dedicate rejection type for axum-extra's `Query`
2022-11-08 20:31:06 +00:00
Jonas Platte 944f388ae0 Add missing cfg's for signed cookie tests 2022-11-05 11:33:27 +01:00
Jonas Platte 410fd49aa9 Fix Cached<T> as the last argument of a handler function (#1428)
* Remove FromRequest impl for Cached<T>

* Add a test for Cached<T> as the last argument of a handler function
2022-09-28 09:06:15 +00:00
Jonas Platte 69d64cecc3 Split RouterService off of Router (#1381) 2022-09-22 12:10:55 +02:00
David PedersenandJonas Platte be624306f4 Only allow last extractor to mutate the request (#1272)
* Only allow last extractor to mutate the request

* Change `FromRequest` and add `FromRequestParts` trait (#1275)

* Add `Once`/`Mut` type parameter for `FromRequest` and `RequestParts`

* 🪄

* split traits

* `FromRequest` for tuples

* Remove `BodyAlreadyExtracted`

* don't need fully qualified path

* don't export `Once` and `Mut`

* remove temp tests

* depend on axum again

Co-authored-by: Jonas Platte <[email protected]>

* Port `Handler` and most extractors (#1277)

* Port `Handler` and most extractors

* Put `M` inside `Handler` impls, not trait itself

* comment out tuples for now

* fix lints

* Reorder arguments to `Handler` (#1281)

I think `Request<B>, Arc<S>` is better since its consistent with
`FromRequest` and `FromRequestParts`.

* Port most things in axum-extra (#1282)

* Port `#[derive(TypedPath)]` and `#[debug_handler]` (#1283)

* port #[derive(TypedPath)]

* wip: #[debug_handler]

* fix #[debug_handler]

* don't need itertools

* also require `Send`

* update expected error

* support fully qualified `self`

* Implement FromRequest[Parts] for tuples (#1286)

* Port docs for axum and axum-core (#1285)

* Port axum-extra (#1287)

* Port axum-extra

* Update axum-core/Cargo.toml

Co-authored-by: Jonas Platte <[email protected]>

* remove `impl FromRequest for Either*`

Co-authored-by: Jonas Platte <[email protected]>

* New FromRequest[Parts] trait cleanup (#1288)

* Make private module truly private again

* Simplify tuple FromRequest implementation

* Port `#[derive(FromRequest)]` (#1289)

* fix tests

* fix docs

* revert examples

* fix docs link

* fix intra docs links

* Port examples (#1291)

* Document wrapping other extractors (#1292)

* axum-extra doesn't need to depend on axum-core (#1294)

Missed this in https://github.com/tokio-rs/axum/pull/1287

* Add `FromRequest` changes to changelogs (#1293)

* Update changelog

* Remove default type for `S` in `Handler`

* Clarify which types have default types for `S`

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>

* remove unused import

* Rename `Mut` and `Once` (#1296)

* fix trybuild expected output

Co-authored-by: Jonas Platte <[email protected]>
2022-08-22 12:23:20 +02:00
David Pedersen e7f1c88cd4 Always store state in an Arc (#1270)
* Add extension and state benchmarks

* wip

* Arc the state everywhere

* don't require `S: Clone`

* fix example
2022-08-17 20:08:24 +00:00
423308de3c Add type safe state extractor (#1155)
* begin threading the state through

* Pass state to extractors

* make state extractor work

* make sure nesting with different states work

* impl Service for MethodRouter<()>

* Fix some of axum-macro's tests

* Implement more traits for `State`

* Update examples to use `State`

* consistent naming of request body param

* swap type params

* Default the state param to ()

* fix docs references

* Docs and handler state refactoring

* docs clean ups

* more consistent naming

* when does MethodRouter implement Service?

* add missing docs

* use `Router`'s default state type param

* changelog

* don't use default type param for FromRequest and RequestParts

probably safer for library authors so you don't accidentally forget

* fix examples

* minor docs tweaks

* clarify how to convert handlers into services

* group methods in one impl block

* make sure merged `MethodRouter`s can access state

* fix docs link

* test merge with same state type

* Document how to access state from middleware

* Port cookie extractors to use state to extract keys (#1250)

* Updates ECOSYSTEM with a new sample project (#1252)

* Avoid unhelpful compiler suggestion (#1251)

* fix docs typo

* document how library authors should access state

* Add `RequestParts::with_state`

* fix example

* apply suggestions from review

* add relevant changes to axum-extra and axum-core changelogs

* Add `route_service_with_tsr`

* fix trybuild expectations

* make sure `SpaRouter` works with routers that have state

* Change order of type params on FromRequest and RequestParts

* reverse order of `RequestParts::with_state` args to match type params

* Add `FromRef` trait (#1268)

* Add `FromRef` trait

* Remove unnecessary type params

* format

* fix docs link

* format examples

* Avoid unnecessary `MethodRouter`

* apply suggestions from review

Co-authored-by: Dani Pardo <[email protected]>
Co-authored-by: Jonas Platte <[email protected]>
2022-08-17 15:13:31 +00:00
David Pedersen 90dbd52ee4 Fix lint warnings (#1267) 2022-08-17 09:41:52 +00:00
David Pedersen f2243c4db0 Make WithRejection::into_inner public (#1266) 2022-08-17 08:59:16 +00:00
Altair BuenoandDavid Pedersen fb21561616 Add WithRejection (#1262)
* new(axum-extra): Added `WithRejection` base impl

Based on @jplatte's version (https://github.com/tokio-rs/axum/issues/1116#issuecomment-1215048273), with slight changes

- Using `From<E::Rejection>` to define the trait bound on a more concise way
- Renamed variables to something more meaningfull

* revert(axum-extra): Removed `with_rejection` feat

* ref(axum-extra): Replaced `match` with `?`

* tests(axum-extra): Added test for `WithRejection`

* examples: Replaced custom `Json` extractor with `WithRejection`

* docs(axum-extra): Added doc to `WithRejection`

* fmt(cargo-check): removed whitespaces

* fmt(customize-extractor-error): missing fmt

* docs(axum-extra): doctest includes `Handler` test

Co-authored-by: David Pedersen <[email protected]>

* docs(axum-extra):` _ `-> `rejection`

Co-authored-by: David Pedersen <[email protected]>

* docs(axum-extra): fixed suggestions

* fix(axum-extra): `WithRejection` manual trait impl

* revert(customize-extractor-error): Undo example changes

refs: d878eede18 , f9200bf4b9

* example(customize-extractor-error): Added reference to `WithRejection`

* docs(axum-extra): Removed `customize-extractor-error` reference

* fmt(axum-extra): cargo fmt

* docs(axum-extra): Added `WithRejection` to CHANGELOG.md

Co-authored-by: David Pedersen <[email protected]>
2022-08-17 07:59:25 +00:00
David Pedersen 01630cfef6 Add sync constructors to CookieJar, SignedCookieJar, and PrivateCookieJar (#1264)
* Add sync constructors to `CookieJar`, `SignedCookieJar`, and `PrivateCookieJar`

* Move to constructor

* use `RequestParts::extract`
2022-08-16 15:42:01 +02:00
Jonas Platte 7cbb7cf135 Use new Cargo features to avoid implicit features for optional dependencies (#1239)
* Fix changelog entry for MSRV change in axum-extra 0.3.5

* Bump MSRV to 1.60 for axum, axum-extra, axum-macros

* Use new Cargo features to avoid implicit features for optional dependencies
2022-08-09 18:43:02 +02:00
Jonas Platte e6fb53fd68 Fix a typo in axum_extra::extract::Query docs (#1201) 2022-07-27 16:32:21 +02:00
David Pedersen 10ab8c7aba Add missing cfg to axum_extra::extract::Form (#1194) 2022-07-26 00:25:45 +02:00
SzudemJ 73041c8988 Avoid exposure of type names by QueryRejection (#1171) 2022-07-18 13:43:18 +00:00
David Pedersen 6b6a415622 Add JsonLines extractor and response (#1093) 2022-06-20 20:49:18 +02:00
David Pedersen 19fe93262f Use impl IntoResponse less in docs (#1049) 2022-05-22 13:41:29 +02:00
Jonas Platte b215a87a19 Add axum_extra::extract::Query 2022-05-17 20:19:24 +02:00
David Pedersen 178e1801e9 Add axum_extra::extract::Form (#1031)
* Add `axum_extra::extra::Form`

* update tokio-util ban
2022-05-15 15:17:45 +00:00
David Pedersen 700617963f Move private and signed cookies behind feature flags (#949)
* move signed cookies into their own module

* Require features for private/signed cookies

* enable "cookie" feature when enabling private/signed cookies

* add `#[cfg]`s in a few more places
2022-04-27 10:11:16 +02:00
David Pedersen 01a4c88d7a Add PrivateCookieJar (#900) 2022-04-01 16:37:55 +02:00
David Pedersen da3ca22301 Fix SignedCookieJar with custom key type (#899) 2022-04-01 11:40:42 +02:00
Paolo Barbolini 1b4c54c6e6 axum-extra: re-export the Expiration and SameSite structs from the cookie crate (#898) 2022-04-01 10:46:43 +02:00
Evan SchwartzandDavid Pedersen 3084dc10ca Accept &str for Redirect (#889)
* Accept &str for Redirect

* Fix doc example

* fix more docs examples

* update changelog

* fix changelog label

Co-authored-by: David Pedersen <[email protected]>
2022-03-31 10:03:06 +02:00
Jonas Platte 80753f8f5c Remove unnecessary mut from (Signed)CookieJar examples (#850) 2022-03-10 12:53:51 +01:00
David PedersenandJonas Platte f045f2356c Add cookie management to axum-extra (#816)
* Cookie management

* fix feature

* Update axum-extra/src/extract/cookie.rs

Co-authored-by: Jonas Platte <[email protected]>

* add tests

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

* less convoluted wording

* changelog

* Make the jars themselves implement `IntoResponseParts`

* dedup tests

* fix docs

Co-authored-by: Jonas Platte <[email protected]>
2022-03-04 10:53:36 +01:00
David PedersenandJonas Platte b1ef0be1a7 Remove RequestParts::take_extensions (#699)
* Remove `RequestParts::take_extensions`

* fix out of date docs

* Remove RequestAlreadyExtracted and replace it with BodyAlreadyExtracted

* fix docs

* fix test

* Update axum-core/src/extract/mod.rs

Co-authored-by: Jonas Platte <[email protected]>

* Remove macro only used once

Co-authored-by: Jonas Platte <[email protected]>
2022-01-23 18:01:52 +01:00
Kai Jewson dfb06e721c Introduce Response type alias as a shorthand for Response<BoxBody> (#590)
* Introduce `Response` type alias as a shorthand

* Don't re-export `Response` at the crate root
2021-12-05 19:16:46 +01:00
Kai Jewson 2b6dba49cb Remove the associated Body type on IntoResponse (#571) 2021-11-28 18:52:18 +01:00
David Pedersen 96b353b556 Add Cached extractor (#565)
* extra: Add `Cached` extractor

`Cached` wraps another extractor and caches its result in request
extensions.

* Use newtype to avoid overriding extensions of the same type

* Rename type param
2021-11-25 10:14:31 +00:00