Commit Graph

223 Commits

Author SHA1 Message Date
David Pedersen e79820dbc4
Support chaining handlers with `one.or(two).or(three)` (#1170)
* WIP: Handler fallbacks

* Docs

* box futures a bit less

* changelog
2022-08-10 10:09:08 +00: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 141198ce19
Declare MSRV in Cargo manifests, not .clippy.toml (#1206) 2022-07-28 15:31:47 +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
David Pedersen b243e171fd
Accept `S::Response: IntoResponse` everywhere (#1165) 2022-07-19 18:55:15 +02:00
SzudemJ 73041c8988
Avoid exposure of type names by QueryRejection (#1171) 2022-07-18 13:43:18 +00:00
David Pedersen 8c9998eab7
Don't derive debug impl for `Resource` (#1153)
We don't actually require `B` to be `Debug` but the derived impl does.
2022-07-11 09:41:41 +02:00
Jonas Platte 8c31bee9bc
docsrs cfg fixes (#1137)
* Remove unused attribute in axum-core

* Fix docs.rs package metadata for axum-extra
2022-07-01 13:35:52 +02:00
David Pedersen a4c820420d
Remove trailing slash redirects (#1119)
* Prepare axum-next branch

* Remove deprecated `extractor_middleware` function (#1077)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` (#948)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}` (#924)

* Allow `Error: Into<Infallible>` for `Route::{layer, route_layer}`

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

* changelog

* fixup changelog

* Panic on overlapping routes in `MethodRouter` (#1102)

* Panic on overlapping routes in `MethodRouter`

* changelog link

* add test to ensure `head` and `get` don't overlap

* Fix changelog

* Prepare axum-next branch

* Remove trailing slash redirects

* changelog link

* Fix changelog

* remove asserting to make make the test more clear

* remove tsr related feature

* Add `RouterExt::route_with_tsr`

* Apply suggestions from code review

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

* Update axum-extra/src/routing/mod.rs

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

* fix typos in docs

* Update axum/CHANGELOG.md

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

* mention `RouterExt::route_with_tsr` in the changelog

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-06-30 00:22:43 +02:00
David Pedersen 905bbfb8e2
axum-extra: Version 0.3.5 (#1125) 2022-06-27 21:08:12 +02:00
David Pedersen 523c7fed88 Depend on right version of tokio-stream 2022-06-25 12:26:37 +02:00
David Pedersen 6b6a415622
Add `JsonLines` extractor and response (#1093) 2022-06-20 20:49:18 +02: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 453202b490
Document all cargo features (#1079) 2022-06-10 08:46:09 +02:00
David Pedersen fbb4786851
axum-extra: Version 0.3.4 (#1074) 2022-06-08 15:58:37 +02:00
David Pedersen 73b1bafbf8
Add `AsyncReadBody` (#1072)
* Add `AsyncReadBody`

* changelog

* sort cargo.toml
2022-06-08 11:02:42 +02:00
David Pedersen 8ff275499b Add #1049 to changelogs 2022-06-06 18:00:52 +02:00
David Pedersen 19fe93262f
Use `impl IntoResponse` less in docs (#1049) 2022-05-22 13:41:29 +02:00
Jonas Platte 1d7878c3c8
axum-extra: 0.3.3 (#1042)
* axum-extra: 0.3.3

* Update axum-extra/CHANGELOG.md

* Update axum-extra/CHANGELOG.md

* depend on axum-macros 0.2.2

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-05-18 20:29:49 +02:00
David Pedersen 5948cde6c1
Support customizing rejections for `#[derive(TypedPath)]` (#1012)
* Support customizing rejections for `#[derive(TypedPath)]`

* changelog

* clean up
2022-05-17 21:36:05 +02:00
Jonas Platte b215a87a19
Add `axum_extra::extract::Query` 2022-05-17 20:19:24 +02:00
David Pedersen 3e722379ac Add changelog link 2022-05-15 20:07:29 +02:00
David Pedersen 61c4e19598
axum-extra: 0.3.2 (#1034) 2022-05-15 20:01:00 +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 cfdac03c8d
axum-extra: Version 0.3.1 (#1016) 2022-05-10 12:05:36 +00:00
David Pedersen 46e6d3493b
axum-macros: Version 0.2.1 (#1015) 2022-05-10 11:46:17 +00:00
David Pedersen b5183afbec
Support wildcards in typed paths (#1003)
* Support wildcards in typed paths

* changelog
2022-05-06 13:05:30 +02:00
David Pedersen 4ff78e552d
Support `Option` and `Result` in typed paths (#1001)
* Support `Option` and `Result` in typed paths

* changelog

* Update axum-extra/CHANGELOG.md

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

* fix one more

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-05-06 09:42:10 +02:00
David Pedersen a3b6cbc99c
axum-extra: Version 0.3.0 (#974)
* axum-extra: Version 0.3.0

* add tower-http update to changelog
2022-04-27 10:27:41 +02: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 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
Fxxxlei 3747650ae9
Remove unnecessary default features for axum from axum-extra (#913)
* Remove unnecessary default features for axum from axum-extra

* Update changelog

Co-authored-by: Leon Felix List <uwdxx@student.kit.edu>
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-04-07 08:24:01 +00:00
David Pedersen 530b0906f7 Fix changelog date 2022-04-03 20:20:50 +02:00
David Pedersen 950dde2664 axum-extra: Version 0.2.1 2022-04-03 20:18:01 +02:00
David Pedersen 405e3f8c44
Add `SpaRouter` (#904) 2022-04-03 18:29:37 +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
David Pedersen 5d0a7b440c axum-extra: Version 0.2.0 2022-03-31 20:48:17 +02:00
David Pedersen d7860ea9e2
Copy over changelogs from v0.4.x branch (#893)
* Copy over changelogs from v0.4.x branch

Preparing to release 0.5

* bump crate versions
2022-03-31 20:21:55 +02:00
Evan Schwartz 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 <david.pdrsn@gmail.com>
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 Pedersen f045f2356c
Add cookie management to axum-extra (#816)
* Cookie management

* fix feature

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

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

* add tests

* Apply suggestions from code review

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

* less convoluted wording

* changelog

* Make the jars themselves implement `IntoResponseParts`

* dedup tests

* fix docs

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-03-04 10:53:36 +01:00
David Pedersen d943ba6d81
Replace `HasRoutes` with `Into<Router>` (#819)
* Move `HasRoutes` into axum

* fix doc test

* Just use `Into<Router>`
2022-03-03 21:50:31 +00:00
David Pedersen bad3abb960 Remove out of date docs
These accidentally weren't removed in https://github.com/tokio-rs/axum/pull/790
2022-03-01 14:09:30 +01:00
David Pedersen f12ab072c5
Add `IntoResponseParts` (#797)
* Add `IntoResponseParts`

* docs

* Add test

* don't allow overriding body or response

* macroify impls

* re-order things a bit

* Fix tests

* Also allow overriding version

* Move things into separate modules

* docs

* clean up

* fix trybuild test

* remove churn

* simplify buliding response

* fixup test

* fix docs typo

* Use `HeaderValue::from_static`, might be faster

* Bring back `impl IntoResponse` in example

* Remove blanket impl to improve error message

* don't need to set `content-type`

* Apply suggestions from code review

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

* changelog

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-02-28 23:04:33 +00:00
David Pedersen da74084146
Easily convert typed paths into URIs (#790)
* Easily convert typed paths into URIs

`#[derive(TypedPath)]` will now also generate `TryFrom<_> for Uri` for
easily converting paths into URIs for use with `Redirect` and friends.

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

* Use a method on the `TypedPath` trait to convert to `Uri`

* fix doc ref

* Update changelogs
2022-02-28 09:58:22 +01:00
Grachev Mikhail ccd7bd91a6
axum-extra: fix typo in CHANGELOG.md (#787)
Signed-off-by: Mikhail Grachev <work@mgrachev.com>
2022-02-24 09:27:50 +01:00
David Pedersen 7a228a584b
Type safe routing (#756)
* wip

* wip

* make macro implement trait

* checkpoint

* checkpoint

* Simplify things quite a bit

* re-export `axum_macros::TypedPath` from `axum_extra`

* docs

* add missing feature

* fix docs link

* fix features

* fix missing imports

* make serde an optional dep again

* ui tests

* Break things up a bit

* Update span for `FromRequest` impls to point to callsite

* make docs feature labels show up automatically

* Apply suggestions from code review

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

* add note about Display/Serialize being compatible

* Update axum-extra/src/routing/typed.rs

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

* fix missing docs link

* what about typed methods?

* Revert "what about typed methods?"

This reverts commit cc1f989467.

* don't allow wildcards for now

* percent encode params

* Update axum-extra/src/routing/typed.rs

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

* rephrase args

* changelog

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2022-02-18 14:13:56 +01:00
David Pedersen 515495d957
Set `content-length` for responses to `HEAD` requests (#734)
* 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 9004a14302
Move `middleware::from_fn` into axum (#719)
* Move `middleware::from_fn` into axum

* changelog

* fix feature

* Rephrase changelog a bit
2022-01-25 10:19:06 +01:00
David Pedersen 4f6e86f026 Fixup changelogs 2022-01-25 09:46:26 +01:00
David Pedersen 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 <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 6d01f3968e
axum-extra: Version 0.1.2 (#705)
- **fix:** Depend on tower with `default_features = false` ([#666])

[#666]: https://github.com/tokio-rs/axum/pull/666
2022-01-13 10:37:56 +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 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
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
2021-12-27 15:23:02 +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
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 a63843d6c5
Release axum, axum-core, and axum-extra (#582) 2021-12-02 20:02:38 +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
Pure White 5a5800c1ae
feat: default to charset=utf-8 for text content type (#554)
* feat: default to charset=utf-8 for text content type

* added changelog && fix comment

* fix workflow
2021-11-25 08:31:30 +00:00
Jonas Platte 69fee5864d
Use .to_owned() instead of .to_string() to turn &str into String (#548) 2021-11-19 22:15:47 +00:00
David Pedersen ab9f1ef993
Change how `Resource`s are added to `Router`s (#544) 2021-11-19 21:59:07 +01:00
David Pedersen f9a437d081
Add `Resource` to axum-extra (#538) 2021-11-17 22:31:43 +00:00
Jonas Platte b43b9ed69d
Add axum_extra::response::ErasedJson (#537) 2021-11-17 22:54:02 +01:00
David Pedersen a16ea65031
Add `axum-extra` crate (#536)
* Add `axum-extra` crate

Empty for now but now we have a place to put stuff.

I'll make a PR for moving over https://github.com/davidpdrsn/axum-resource.

* remove `authors` field from `Cargo.toml`s
2021-11-17 20:00:32 +00:00