1
0
Fork 0
mirror of https://github.com/tokio-rs/axum.git synced 2025-03-20 05:58:49 +01:00
Commit graph

549 commits

Author SHA1 Message Date
David Pedersen
9ddcd22031
axum-debug: Version 0.3.3 () 2022-01-31 22:06:43 +01:00
David Pedersen
c1cc4b515a Update axum-macros changelog with initial release date 2022-01-31 20:06:59 +01:00
Ibraheem Ahmed
2eab37280c
update matchit to 0.4.6 () 2022-01-31 19:06:24 +00:00
Eray Karatay
720b2ba0c4
fix crates.io links () 2022-01-31 17:09:55 +01:00
David Pedersen
515495d957
Set content-length for responses to HEAD requests ()
* Set `content-length` internally in `Router`

* changelog

* require `B: HttpBody` at the `impl`

* add changelog refs
2022-01-31 13:48:51 +01:00
David Pedersen
84df7eaa38 MethodRouter::fallback docs follow up
https://github.com/tokio-rs/axum/pull/733#discussion_r795244092
2022-01-31 09:37:29 +01:00
David Pedersen
513766b9e7
Set Allow header when returning 405 Method Not Allowed () 2022-01-30 21:41:34 +01:00
David Pedersen
a04fc42d75
Rework middleware docs ()
* rework middleware docs

* Apply suggestions from code review

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-01-30 20:09:18 +01:00
David Pedersen
911c4a788e
Support opt-out of extra derived traits for rejections for #[derive(FromRequest)] ()
* Handle structs without fields

* Support opt-out of derived rejection traits

* Handle duplicate opt outs

* Improve error if opting out of `Display` or `Debug` but not `Error`

* document `rejection_derive`

* Handle using both `via` and `rejection_derive`

* don't derive debug for `RejectionDeriveOptOuts`

* Update axum-macros/src/from_request.rs

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-01-28 09:54:38 +00:00
David Pedersen
f6fc5ed80c
Move axum-debug into axum-macros ()
* Move axum-debug into axum-macros

* fix ref to axum-macros in changelog

* Apply suggestions from code review

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-01-26 23:27:22 +01:00
Alex
b1283e9708
Fix year for the 0.4.4 release () 2022-01-26 08:17:39 +01:00
YuKun Liu
c0473f2b6f
Expand WebSocket example to match on Message () 2022-01-25 15:31:33 +00:00
FlakM
32c9ab3c56
Add sqlx example with migrations ()
* Add sqlx example with migrations

Simple use case for sqlx based on tokio postgres example.
Sqlite database is created on execution in ./target directory
and migrations are then run against it.

* sqlx example uses postgres instead of sqlite3

Also removed migrations and database creation code.
2022-01-25 16:20:00 +01:00
David Pedersen
e4c389c94d
Add axum-macros crate with #[derive(FromRequest)] ()
* initial working impl

* support `#[from_request(via(...))]`

* support extracting the whole thing at once

* rely on type inference

* fix footgun

* fix typo

* generate rejection enums

* move tests to trybuild

* minor clean up

* docs

* Support multiple generic extractors with same "via" type

* support `Result` as well

* Update axum-macros/src/from_request.rs

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

* Add `#[automatically_derived]`

* remove needless `#[derive(Debug)]` on macro types

* Fix error messages that different for some reason

* Update axum-macros/src/lib.rs

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

* add more `#[automatically_derived]`

* support same types in tuple structs

* update docs

* prep axum-macros for release

* address review feedback

* Update axum-macros/src/lib.rs

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

* Update axum-macros/src/lib.rs

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>

* Update known limitation

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-01-25 15:05:50 +01:00
David Pedersen
9004a14302
Move middleware::from_fn into axum ()
* Move `middleware::from_fn` into axum

* changelog

* fix feature

* Rephrase changelog a bit
2022-01-25 10:19:06 +01:00
David Pedersen
208720be53 Clarity Err usage in IntoResponseHeaders 2022-01-25 09:46:38 +01:00
David Pedersen
4f6e86f026 Fixup changelogs 2022-01-25 09:46:26 +01:00
David Pedersen
e7051322d3 Make IntoResponseHeaders members hidden 2022-01-23 20:25:12 +01:00
David Pedersen
2546be04f6 Clean up docs for IntoResponseHeaders 2022-01-23 20:25:12 +01:00
David Pedersen
f96111851d Remove mention of IntoResponseHeaders from axum-debug 2022-01-23 20:25:12 +01:00
David Pedersen
d4849820ce Move Headers into axum 2022-01-23 20:25:12 +01:00
Jonas Platte
bf83f34617 Add trait IntoResponseHeaders ()
* Introduce IntoResponseHeaders trait

* Implement IntoResponseHeaders for HeaderMap

* Add impl IntoResponse for impl IntoResponseHeaders

… and update IntoResponse impls that use HeaderMap to be generic instead.

* Add impl IntoResponseHeaders for Headers

… and remove IntoResponse impls that use it.

* axum-debug: Fix grammar in docs

* Explain confusing error message in docs
2022-01-23 18:01:52 +01:00
David Pedersen
b1ef0be1a7 Remove RequestParts::take_extensions ()
* 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 <jplatte@users.noreply.github.com>

* Remove macro only used once

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-01-23 18:01:52 +01:00
David Pedersen
184ea656c0 Change HeaderMap extractor to clone the headers ()
* Change `HeaderMap` extractor to clone the headers

* fix docs

* changelog

* inline variable

* also add changelog item to axum

* don't list types from axum in axum-core's changelog

* document that `HeaderMap::from_request` clones the headers

* fix typo

* a few more typos
2022-01-23 18:01:52 +01:00
Sabrina Jewson
d5694f0d0d Make sse::Event build event as a BytesMut ()
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-01-23 18:01:52 +01:00
Jonas Platte
e0a463b463 Optional extractor extensions ()
* Fix inconsistent indentation in axum/Cargo.toml

* Make MatchedPath and OriginalUri extractors and logic for them optional

… they add some runtime cost to handling any request that goes through
a Router, which only makes sense if they actually get used.

Enable both features by default for convenience.
2022-01-23 18:01:52 +01:00
David Pedersen
d97f2aeae6 Make TypedHeaderRejectionReason #[non_exhaustive] ()
* Make `TypedHeaderRejectionReason` `#[non_exhaustive]`

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

* add changelog pr link
2022-01-23 18:01:52 +01:00
David Pedersen
5d79c638f4 Require Output = () on WebSocketStream::on_upgrade ()
Fixes https://github.com/tokio-rs/axum/issues/636
2022-01-23 18:01:52 +01:00
Nylonicious
455fc46bf3 Change error type for RequestParts::try_into_request () 2022-01-23 18:01:52 +01:00
Nick Ashley
9b4232b786 Replace public use of mime crate with &str ()
Replaces `Field::content_type`'s return type with `&str`.
This is a breaking change.

Closes 
2022-01-23 18:01:52 +01:00
Lainera
4df4e07e10
add axum-msgpack crate to ECOSYSTEM.md () 2022-01-22 10:13:53 +01:00
David Pedersen
830bfdbe3c
Change TestClient to not follow redirects ()
Makes it more obvious what actually goes on
2022-01-21 17:32:12 +01:00
Aaron Erhardt
50f42d8071
Fix path route in extractor docs () 2022-01-18 13:22:54 +00:00
David Pedersen
5ffab810c0
Update to changed compiler error in 1.58 ()
The trybuild tests needed to be updated for 1.58. We only run the tests
on stable (but build on other toolchains).
2022-01-14 09:32:34 +01:00
David Pedersen
6d01f3968e
axum-extra: Version 0.1.2 ()
- **fix:** Depend on tower with `default_features = false` ([])

[]: https://github.com/tokio-rs/axum/pull/666
2022-01-13 10:37:56 +01:00
David Pedersen
5fe981a1da
axum: Version 0.4.4 ()
- **fixed:** Fix using incorrect path prefix when nesting `Router`s at `/` ([])
- **fixed:** Make `nest("", service)` work and mean the same as `nest("/", service)` ([])
- **fixed:** Replace response code `301` with `308` for trailing slash redirects. Also deprecates
  `Redirect::found` (`302`) in favor of `Redirect::temporary` (`307`) or `Redirect::to` (`303`).
  This is to prevent clients from changing non-`GET` requests to `GET` requests ([])

[]: https://github.com/tokio-rs/axum/pull/691
[]: https://github.com/tokio-rs/axum/pull/682
2022-01-13 10:37:33 +01:00
Nick Ashley
007a0e85f2
Use 308 instead of 301 for trailing slash redirects ()
* Use 308 status instead of 301 when redirecting

For redirects resulting from requests to paths with a trailing slash,
use 308 instead of 301 to prevent non-GET requests (POST, PUT, etc) from
being changed to GET.

For example, (assuming a route for /path is defined)...
  - Old behavior results in:
  POST /path/ -> GET /path

  - New behavior results in:
  POST /path/ -> POST /path

Fixes 

* Add deprecation notice to found()

Deprecates found() due to its use of HTTP 302

* rustfmt

* Use dedicated redirect method

Use Redirect::permanent instead of re-implementing its functionality

* Remove deprecated method from example

Replace usages of Redirect:found with Redirect::to and Redirect::temporary as appropriate

* Fix panic in oauth example

Previously the example would panic if a request was made without the
`Cookie` header. Now the user is redirected to the login page as
expected.

* Update CHANGELOG

* Revert pub TypedheaderRejection fields

* Fix clippy lint

* cargo fmt

* Fix CHANGELOG link

* Adhere to implicit line length limit
2022-01-12 15:14:06 +01:00
Dr. David A. Kunz
5512ebcd23
chore: Fix typo in middleware.md () 2022-01-11 22:56:33 +00:00
David Pedersen
d181867355
Fix nesting Router at / leading to double slash in the path ()
* 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 Pedersen
d6ce99190b
Document extracting OriginalUri directly via request extensions ()
* 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 <jplatte@users.noreply.github.com>

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-01-06 10:35:11 +00:00
David Pedersen
6d24a8695f
Add SSE tests ()
* 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 ()
* 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 () 2022-01-03 15:37:40 +01:00
Patrick
e0082a3f87
Fix the link to "Routing to services and backpressure" ()
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 ()
* 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 () 2021-12-29 20:12:50 +01:00
Jonas Platte
616a43aaa3
Simplify graceful shutdown () 2021-12-28 16:23:07 +01:00
David Pedersen
5698fb8be9
Add metrics example () 2021-12-28 15:58:48 +01:00
Sabrina Jewson
031e0fd472
Store Bytes in ErasedJson () 2021-12-28 10:41:21 +00:00