Commit Graph
512 Commits
Author SHA1 Message Date
Dr. David A. Kunz 5512ebcd23 chore: Fix typo in middleware.md (#700) 2022-01-11 22:56:33 +00:00
David Pedersen d181867355 Fix nesting Router at / leading to double slash in the path (#691)
* Fix nesting router at `/`

Fixes https://github.com/tokio-rs/axum/issues/690

* Allow nesting at `""`

* changelog

* remove outdated test
2022-01-06 12:12:24 +01:00
David PedersenandJonas Platte d6ce99190b Document extracting OriginalUri directly via request extensions (#688)
* Document extracting `OriginalUri` directly via request extensions

Fixes https://github.com/tokio-rs/axum/issues/684

* fix example

* Update axum/src/extract/request_parts.rs

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

Co-authored-by: Jonas Platte <[email protected]>
2022-01-06 10:35:11 +00:00
David Pedersen 6d24a8695f Add SSE tests (#652)
* Add SSE tests

* Simplify keep alive test a bit

* More robust keep-alive tests

* rename a bit
2022-01-03 18:48:50 +01:00
David Pedersen 86331613f4 Add some debug assertions (#686)
* Add some debug assertions

As discussed in Discord its probably worth having debug assertions for
these two cases, should we accidentally break them in the future.

* remove assertion in `OriginalUri`
2022-01-03 15:32:35 +00:00
David Pedersen 8cd9c478fe Document passing state to handlers via closure captures (#683) 2022-01-03 15:37:40 +01:00
Patrick e0082a3f87 Fix the link to "Routing to services and backpressure" (#680)
In `Router::route`, the link to the "Routing to services and
backpressure" section on the crate documentation page directed to
<https://docs.rs/#routing-to-services-and-backpressure>. This change
makes it direct to the main crate documentation page.
2021-12-31 22:32:55 +01:00
Nylonicious 8411b78736 Document calling extractors in FromRequest impl (#679)
* Document calling extractors in FromRequest impl

* Fix typo

* Apply suggested changes
2021-12-31 16:16:33 +01:00
David Pedersen 044d35d193 Link to another benchmark 2021-12-29 23:03:01 +01:00
lz1998 15e03a4e6b ecosystem: Add book management (#675) 2021-12-29 20:12:50 +01:00
Jonas Platte 616a43aaa3 Simplify graceful shutdown (#673) 2021-12-28 16:23:07 +01:00
David Pedersen 5698fb8be9 Add metrics example (#671) 2021-12-28 15:58:48 +01:00
Sabrina Jewson 031e0fd472 Store Bytes in ErasedJson (#672) 2021-12-28 10:41:21 +00:00
Guy Lapid d602682821 Add support for returning pretty JSON response in axum_extra::response::ErasedJson (#662) 2021-12-28 09:19:24 +00:00
David Pedersen 4fd7e927ba Document how to pass state to middleware::from_fn (#669) 2021-12-27 23:53:50 +01:00
David Pedersen 1020d0144b Improve middleware examples using auth (#668)
* Make `middleware::from_fn` examples less secure

* Also improve `extractor_middleware` example
2021-12-27 23:34:37 +01:00
David Pedersen 9d62b5c060 Mention middleware::from_fn in axum’s docs (#670)
Fixes https://github.com/tokio-rs/axum/issues/667
2021-12-27 23:30:08 +01:00
David Pedersen de37a3e737 Tweak tower dependency in axum-extra (#666)
Fixes https://github.com/tokio-rs/axum/issues/659
2021-12-27 23:28:58 +01:00
Jonas Platte a3e19465ac Move header name validity checks to compile time (#661) 2021-12-27 18:25:47 +01:00
Sabrina Jewson 7df611319e Fix axum-extra's optional feature documentation (#663) 2021-12-27 18:12:46 +01:00
David Pedersen 9f5f29dfba axum-extra: Version 0.1.1 (#658)
- Add `middleware::from_fn` for creating middleware from async functions ([#656])

[#656]: https://github.com/tokio-rs/axum/pull/656
axum-extra-v0.1.1
2021-12-27 15:23:02 +01:00
Jonas Platte 0a399ed0fa A few small refactorings (#655)
* Simplify json content-type check

* Import HeaderMap from http instead of from headers

The headers crate is an optional dependency and its HeaderMap re-export
is `#[doc(hidden)]`.

* Use headers re-export in axum in examples
2021-12-27 14:02:38 +01:00
David Pedersen f4716084a7 Add middleware::from_fn for creating middleware from async fns (#656)
* Add `middleware::from_fn` for creating middleware from async fns

* More trait impls for `Next`

* Make `Next::run` consume `self`

* Use `.router_layer` in example, since middleware returns early

* Actually `Next` probably shouldn't impl `Clone` and `Service`

Has implications for backpressure and stuff

* Simplify `print-request-response` example

* Address review feedback

* add changelog link
2021-12-27 14:01:26 +01:00
ttys3and荒野無燈 3841ef44d5 Fix session cookie example (#638)
* refactor: refine session cookie example

* refactor: refine session_cookie extraction

* refactor: avoid to_owned()

* chore: refine debug log

Co-authored-by: 荒野無燈 <[email protected]>
2021-12-22 15:27:13 +01:00
David Pedersen 4c48efc861 axum: Version 0.4.3 (#650) axum-v0.4.3 2021-12-21 15:41:03 +01:00
Jonas Platte ce6ad399ef Fix a typo (#635) 2021-12-17 13:15:07 +01:00
Jonas Platte f7049054bf Re-export the headers crate when the headers feature is active (#630) 2021-12-15 15:14:03 +01:00
lz1998andDavid Pedersen dea36db400 Use HttpBody type alias internally (#624)
* use 'crate::body::HttpBody' instead of 'http_body::Body'

* use 'crate::body::Bytes' instead of 'bytes::Bytes'

* rustfmt

* fix warning

* Update axum/src/routing/method_routing.rs

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

* Update axum/src/routing/method_routing.rs

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

Co-authored-by: David Pedersen <[email protected]>
2021-12-14 12:58:45 +01:00
David Pedersen 4625e1953b Allow duplicate itoa dependency (#626)
Once the community has updated to itoa 1.0 we can remove this.
2021-12-14 11:56:16 +01:00
David Pedersen ba42783df2 Example for defining routes and handlers close together (#621) 2021-12-12 23:54:18 +01:00
David Pedersen c50b55384c Add ExtensionsAlreadyExtracted to PathRejection (#619)
* Add `ExtensionsAlreadyExtracted` to `PathRejection`

* format imports

* changelog
2021-12-12 23:51:18 +01:00
David Pedersen ecf3359980 Fix misc warnings from CI (#620) 2021-12-12 17:21:29 +01:00
Kai JewsonandDavid Pedersen d9bf100216 Don't drop leading spaces in SSE responses (#600)
* Don't drop leading spaces in SSE responses

* Mention leading space fix in changelog

Co-authored-by: David Pedersen <[email protected]>
2021-12-12 16:11:15 +00:00
Kai Jewson 980a0a466e Simplify Websocket implementation (#615)
* Remove `WebSocketUpgradeResponse`

* Move protocol selection to `WebSocketUpgrade::protocols`
2021-12-12 17:05:28 +01:00
Kai JewsonandDavid Pedersen 6feea82d61 Enforce stronger validation of SSE values (#599)
* Enforce stronger validation of SSE values

* Mention `sse::Event` strictness in changelog

Co-authored-by: David Pedersen <[email protected]>
2021-12-12 16:03:20 +00:00
Kai Jewson 9344d27cfa Improve documentation of sse::Event (#601) 2021-12-12 16:56:07 +01:00
Kai Jewson 9ed18d92cf Use AtomicU32 in RouteId (#616) 2021-12-12 14:19:30 +00:00
Kai Jewson b7cc3d4645 Clarify that servers shouldn't implement Websocket ping/pong (#617) 2021-12-12 15:08:00 +01:00
Jonas Platte b1623ce7f2 Add AddExtension::layer (#607) 2021-12-10 22:56:56 +01:00
Jonas Platte c8c0bb2ce1 Fix a typo (#605) 2021-12-10 18:34:31 +01:00
David Pedersen 3a259dcec7 axum-debug: Version 0.3.2 (#598)
- Support checking `FromRequest` bounds for extractors whose request body is something else than
  `axum::body::Body`. Use `#[debug_handler(body = YourBodyType)]` to use a different request body
  type ([#595])

[#595]: https://github.com/tokio-rs/axum/pull/595
axum-debug-v0.3.2
2021-12-09 10:52:31 +01:00
David Pedersen 8895926f73 Support customizing the request body type in #[debug_handler] (#595) 2021-12-08 19:37:18 +01:00
David Pedersen 4b85b227e1 Update changelog with v0.3.4
This was shipped from the `v0.3.x` branch so wasn't moved to `main`.
2021-12-08 18:38:14 +01:00
David Pedersen 8e439b17f3 Clean up deny.toml (#597) 2021-12-08 18:37:02 +01:00
David Pedersen 9f6be24ecd axum: Version 0.4.2 (#592)
* axum: Version 0.4.2

This time depending on the correct version of axum-core.

* add missing changelog links
axum-v0.4.2
2021-12-06 12:03:13 +00:00
David Pedersen 8e1341d1f6 Release axum, axum-core, and axum-debug (#591) axum-v0.4.1 axum-core-v0.1.1 axum-debug-v0.3.1 2021-12-06 10:30:09 +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
David Pedersen cbb34869d8 Fix debug_handler for Result<impl IntoResponse, Error> and friends (#588)
Fixes #587
2021-12-04 18:24:58 +01:00
David Pedersen 628921bcad axum-debug 0.3 (#586)
Forgot to ship this one so the latest version would generate wrong code.
axum-debug-v0.3.0
2021-12-03 22:42:10 +01:00
David Pedersen 6dcb406ab8 Remove axum-handle-error-extract from ECOSYSTEM.md
Its been integrated into axum 0.4.
2021-12-02 20:47:54 +01:00