Commit graph

19 commits

Author SHA1 Message Date
Zheng Li
19101f624d
Replace async_trait with AFIT / RPITIT (#2308)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2024-09-28 21:27:11 +00:00
Jonas Platte
2fb6cea732
Remove unused dependencies from examples (#2934) 2024-09-25 03:44:47 -04:00
Weipeng Hong
ef1448a3f5
Use env!("CARGO_CRATE_NAME") in the example to simplify the tracing setup code (#2884) 2024-08-24 08:36:08 +02:00
Chris Pick
035c8a36b5
Fix a few typos in docs and comments (#2808) 2024-06-27 08:45:57 +02:00
David Pedersen
43b14a5f02
Update to latest versions of hyper and http-body (#1882)
Co-authored-by: Michael Scofield <mscofield0@tutanota.com>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2023-11-23 11:03:03 +00:00
David Pedersen
9eb502c768
Use tuples instead of ServiceBuilder internally (#2229) 2023-09-17 10:56:47 +02:00
David Pedersen
c97967252d Add serve function and remove Server re-export (#1868) 2023-04-21 17:45:31 +02:00
David Pedersen
6703f8634c Remove B type param: Follow ups (#1789)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Michael Scofield <mscofield0@tutanota.com>
2023-04-21 17:45:31 +02:00
David Pedersen
4e4c29175f Remove B type param (#1751)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Michael Scofield <mscofield0@tutanota.com>
2023-04-21 17:45:31 +02:00
Jonas Platte
dc480f7b0e
Re-integrate examples into the root workspace (#1466)
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2023-03-10 12:02:11 +01:00
David Pedersen
f726f16b6d
Update to tower-http 0.4 (#1783) 2023-02-24 20:51:30 +00:00
tottoto
6c133be5b7
Refactor initializing tracing-subscriber in examples (#1596)
* Refactor initializing tracing-subscriber

* Revert "Refactor initializing tracing-subscriber"

This reverts commit 0876260bf9 in favor of tracing_subscriber::registry.

* Use EnvFilter::try_from_default_env in chat example

* Use EnvFilter::try_from_default_env in examples
2022-11-30 10:46:19 +01:00
David Pedersen
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 <jplatte+git@posteo.de>

* 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 <jplatte+git@posteo.de>

* remove `impl FromRequest for Either*`

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>

* 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 <jplatte+git@posteo.de>

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>

* remove unused import

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

* fix trybuild expected output

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
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
David Pedersen
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 <dani.pardo@inmensys.com>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-08-17 15:13:31 +00:00
David Pedersen
93251fa203
Bump MSRV to 1.56 and update to the 2021 edition (#1098) 2022-06-17 20:11:35 +02:00
David Pedersen
1fe4558362
Move examples to separate workspace (#978)
* Move examples to separate workspace

* update commands to run examples

* remove debug
2022-04-29 18:53:41 +02:00
David Pedersen
79f6cde3b1
Update to tower-http 0.3.0 (#965)
* Update to tower-http 0.3.0

* changelog link
2022-04-25 14:59:16 +00:00
David Pedersen
33ee55e52c
Add example for consuming request body in middleware and extractor (#861) 2022-03-18 15:41:38 +00:00