Commit Graph
100 Commits
Author SHA1 Message Date
David PedersenandGitHub 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 PedersenandGitHub 5bb924b3a2 Implement IntoResponse and IntoResponseParts for http::Extensions (#975)
* Implement `IntoResponse` and `IntoResponseParts` for `http::Extensions`

Requires a new release of `http`.

* remove http patch

* changelog ref
2022-04-29 17:28:24 +02:00
David PedersenandGitHub 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 PedersenandGitHub 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 PedersenandGitHub a723ed1453 axum: Version 0.5.4 (#973) 2022-04-26 16:50:44 +02:00
David PedersenandGitHub 0702c59c7d axum-core: Version 0.2.3 (#966) 2022-04-26 14:19:47 +00:00
David PedersenandGitHub 23f20ea1f3 Replace ByteStr with Arc<str> (#971) 2022-04-26 10:16:38 +02:00
David PedersenandGitHub 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
061e66c236 axum: Version 0.5.3 (#947)
* axum: Version 0.5.3

* Update axum/CHANGELOG.md

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

Co-authored-by: Jonas Platte <[email protected]>
2022-04-19 17:00:51 +02:00
David PedersenandGitHub 2adb34c8aa Revert "Allow Error: Into<Infallible> for Route::{layer, route_layer} (#924)" (#946)
This reverts commit ca7ecb159b.
2022-04-19 16:47:27 +02:00
David Pedersen 883a1cfd8f axum: Version 0.5.2 2022-04-19 16:19:43 +02:00
David Pedersen 598e6935df axum-core: Version 0.2.2 2022-04-19 16:17:52 +02:00
David PedersenandGitHub ca7ecb159b 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
2022-04-19 16:16:54 +02:00
David PedersenandGitHub afcefb4a70 Add AppendHeaders (#927)
* Add `AppendHeaders`

* axum changelog
2022-04-17 23:14:04 +02:00
David Pedersen 3e716f303f axum: Version 0.5.1 2022-04-03 20:23:18 +02:00
David Pedersen bcda1a97db axum-core: Version 0.2.1 2022-04-03 20:21:16 +02: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 PedersenandGitHub 405e3f8c44 Add SpaRouter (#904) 2022-04-03 18:29:37 +02:00
David PedersenandGitHub 2270cf7b3e Add "stream to file" example (#903)
* Add "stream to file" example

* add title tag
2022-04-03 12:28:29 +02:00
David PedersenandGitHub 01a4c88d7a Add PrivateCookieJar (#900) 2022-04-01 16:37:55 +02:00
David PedersenandGitHub da3ca22301 Fix SignedCookieJar with custom key type (#899) 2022-04-01 11:40:42 +02:00
David Pedersen 5d0a7b440c axum-extra: Version 0.2.0 2022-03-31 20:48:17 +02:00
David Pedersen f69d2dbf40 axum-macros: Version 0.2.0 2022-03-31 20:45:01 +02:00
David Pedersen cf12b3aa0f Fix version of axum used locally 2022-03-31 20:45:01 +02:00
David Pedersen fec64bc1b6 axum: Version 0.5.0 2022-03-31 20:37:45 +02:00
David PedersenandGitHub fba2faa38f axum-core: Version 0.2.0 (#894) 2022-03-31 20:36:12 +02:00
David PedersenandGitHub 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
David PedersenandGitHub 21552fe434 Remove bound from into_make_service_with_connect_info (#892)
Fixes #859
2022-03-31 16:49:49 +00:00
David PedersenandGitHub 56e2d57320 Change Handler to have an associated Future type (#879)
* Change `Handler` to have an associated `Future` type

This removes `#[async_trait]` from `Handler` and replaces that with an
associated `Future` type.

As hinted at in #878 I'm working on something with types that need to
implement `Handler`. I'm doing that by wrapping other `Handler` types so
I can implement `Handler` by simply delegating and thus don't need to
allocate another box for `#[async_trait]`. This change makes that
possible.

It does make `Handler` less ergonomic to implement but thats a very
niche feature so I'm fine with that. It wouldn't be appropriate for
`FromRequest` IMO.

* changelog
2022-03-21 13:32:06 +00:00
David PedersenandGitHub 6175f95f41 Unseal handler trait (#878) 2022-03-21 11:55:31 +01:00
David PedersenandGitHub 2c985246ba Fix out of date docs for Json (#871)
Fixes https://github.com/tokio-rs/axum/issues/865
2022-03-19 01:24:28 +01:00
437fe5b931 Make status codes for JsonRejection more precise (#868)
* Fix status codes for `JsonRejection` rejections

Fixes #865

* Apply suggestions from code review

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

Co-authored-by: Jonas Platte <[email protected]>
2022-03-18 16:53:39 +01:00
David PedersenandGitHub 33ee55e52c Add example for consuming request body in middleware and extractor (#861) 2022-03-18 15:41:38 +00:00
David PedersenandGitHub a0ae0c48aa Make RequestParts::body_mut return &mut Option<B> (#869) 2022-03-18 15:39:13 +00:00
David PedersenandGitHub debc3f5be9 Don't run nightly on CI (#870)
* Exclude sqlx example

Getting an ICE
https://github.com/tokio-rs/axum/runs/5602144413?check_suite_focus=true.
Will look into that later.

* actually it was nightly's fault

* and don't test things on nightly
2022-03-18 16:28:23 +01:00
88974f4299 Add missing changelog items (#845)
* Add missing changelog items

* Update axum/CHANGELOG.md

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

Co-authored-by: Jonas Platte <[email protected]>
2022-03-09 15:07:41 +00:00
David Pedersen 14960e9a11 fix changelog links 2022-03-09 15:43:54 +01:00
David PedersenandGitHub 401c7a324a Fix routing for opaque nested services (#842)
* Fix routing for opaque nested services

* Also test `MatchedPath`

* clean up and more comments
2022-03-09 11:25:06 +01:00
David PedersenandGitHub 70e3024068 Don't set extension we never use (#844)
* Remove unused internal helper

* Don't set extension we never use
2022-03-09 11:05:24 +01:00
David PedersenandGitHub f9a94ca7eb Add security note about extract::Host (#839) 2022-03-09 10:18:12 +01:00
David Pedersen 19eda2f566 fix ups: include all crates in workspace 2022-03-08 21:32:54 +01:00
David PedersenandGitHub dfa2e3b09f Fix nesting of opaque services that paths that contain params (#841)
* checkpoint

* fix it

* more consistent macros

* fix msrv
2022-03-08 21:27:44 +01:00
David PedersenandGitHub 0600eff31a Use IntoResponse rather than Response::builder internally (#837) 2022-03-07 16:49:03 +01:00
David PedersenandGitHub 87a2b0dac1 Implement IntoResponseParts for Option<T> (#838) 2022-03-07 16:37:34 +01:00
David PedersenandGitHub b05a5c6dfe Make it more obvious that NEST_TAIL_PARAM is reserved (#836) 2022-03-06 16:01:14 +00:00
David PedersenandGitHub a438e6b106 Refactor storing URL params in extensions (#833) 2022-03-06 12:41:16 +01:00
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 PedersenandGitHub ae22154979 Add example for implementing IntoResponseParts (#825) 2022-03-04 10:53:17 +01:00
David PedersenandGitHub 1614ef7a22 Fix inconsistent double slash when nesting routes (#824) 2022-03-04 09:28:44 +01:00
David PedersenandGitHub 90e74f12c4 Requires paths start with a / (#823)
* Requires routes to start with `/`

* Also check routes in `TypedPath`

* changelog

* changelog links
2022-03-03 23:24:27 +00:00
David PedersenandGitHub 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 PedersenandGitHub 1c8f09268b Implement IntoResponseParts for more tuples (#817) 2022-03-03 08:07:00 +01:00
David PedersenandGitHub 5f54855b05 Remove IntoResponse and IntoResponseParts impls for Version (#815) 2022-03-02 13:07:16 +00:00
David PedersenandGitHub 84c725a1ae Make IntoResponseParts more flexible (#813)
* Make `IntoResponseParts` more flexible

* fix `impl<T> IntoResponseParts for TypedHeader<T>`

* fix
2022-03-02 11:41:14 +00:00
David PedersenandGitHub 24359ebd4d Move TypedHeader into root (#803) 2022-03-01 16:00:42 +00:00
David PedersenandGitHub 2428d99081 Export AddExtension from middleware (#811)
* Export `AddExtension` from `middleware`

* Move `AddExtension` into `extension` module
2022-03-01 13:59:33 +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 PedersenandGitHub 2de202da40 Remove AddExtensionLayer (#807)
* Remove `AddExtensionLayer`

Its deprecated on 0.4.x so we can remove it from `main`.

* changelog
2022-03-01 13:59:43 +01:00
David PedersenandGitHub 094fd71d1a Move Extension into root (#804) 2022-03-01 09:12:45 +01:00
David PedersenandGitHub a2b568c7c1 Implement tower::Layer for Extension (#801)
* Implement `tower::Layer` for `Extension`

* changelog
2022-03-01 00:39:22 +01:00
David PedersenandGitHub 0d05b5e31f Remove deprecated APIs (#800)
* Remove deprecations APIs

* changelog
2022-02-28 23:22:21 +00:00
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 <[email protected]>

* changelog

Co-authored-by: Jonas Platte <[email protected]>
2022-02-28 23:04:33 +00:00
David PedersenandGitHub 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
David PedersenandGitHub 8175b9108f Improve error for missing extension (#795) 2022-02-25 19:42:36 +01:00
David PedersenandGitHub 4ccc4bea71 Update to tokio-tungstenite 0.17 (#791)
Fixes https://github.com/tokio-rs/axum/issues/781
2022-02-25 10:42:09 +00:00
David Pedersen 07e8a6d8fe Update trybuild test to rust 1.59 output 2022-02-25 11:30:10 +01:00
David PedersenandGitHub e781b7b936 Fix some out of date docs (#784)
Since https://github.com/tokio-rs/axum/pull/698 this section about
`HeaderMap` removing the headers from the request is no longer true.
2022-02-24 16:22:52 +01:00
David PedersenandGitHub 113a15a713 Document sharing state between handler and middleware (#783)
* Fix heading levels

* Document passing state from middleware to handlers
2022-02-22 16:14:18 +01:00
David PedersenandGitHub 49d8fc5093 Make middleware::from_fn response future public (#778)
* Make `middleware::from_fn` response future public

* Make module name consistent with tower
2022-02-22 13:30:47 +01:00
David Pedersen 50606517ac Allow duplicate tokio-util dependency for now
Requires a new release of h2 to fix
2022-02-22 12:19:33 +01:00
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 <[email protected]>

* add note about Display/Serialize being compatible

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

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

* 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 <[email protected]>

* rephrase args

* changelog

Co-authored-by: Jonas Platte <[email protected]>
2022-02-18 14:13:56 +01:00
David Pedersen 8b551dcbf2 Fix broken docs link 2022-02-15 22:16:23 +01:00
David PedersenandGitHub c135436cc9 Fix setting content-length: 0 for HEAD responses with compression middleware (#755)
* Fix getting `content-length` for `chunked` responses

Fixes #747

* changelog

* Fix `cargo deny bans`

https://github.com/tokio-rs/axum/pull/753 will fix things properly
2022-02-14 09:56:08 +00:00
David PedersenandGitHub 409a6651f5 Update dependencies (#753) 2022-02-12 17:16:14 +00:00
David PedersenandGitHub 1e51ea9423 Fix rejection status codes (#751) 2022-02-09 10:19:31 +00:00
David PedersenandGitHub 15914c4f15 Remove axum-debug code (#740) 2022-01-31 22:46:44 +01:00
David PedersenandGitHub 9ddcd22031 axum-debug: Version 0.3.3 (#737) 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
David PedersenandGitHub 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 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 PedersenandGitHub 513766b9e7 Set Allow header when returning 405 Method Not Allowed (#733) 2022-01-30 21:41:34 +01:00
a04fc42d75 Rework middleware docs (#732)
* rework middleware docs

* Apply suggestions from code review

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

Co-authored-by: Jonas Platte <[email protected]>
2022-01-30 20:09:18 +01:00
911c4a788e Support opt-out of extra derived traits for rejections for #[derive(FromRequest)] (#729)
* 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 <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>
2022-01-28 09:54:38 +00:00
f6fc5ed80c Move axum-debug into axum-macros (#724)
* Move axum-debug into axum-macros

* fix ref to axum-macros in changelog

* Apply suggestions from code review

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

Co-authored-by: Jonas Platte <[email protected]>
2022-01-26 23:27:22 +01:00
e4c389c94d Add axum-macros crate with #[derive(FromRequest)] (#718)
* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* Update axum-macros/src/lib.rs

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

* Update known limitation

Co-authored-by: Jonas Platte <[email protected]>
2022-01-25 15:05:50 +01:00
David PedersenandGitHub 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 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
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
David Pedersen 184ea656c0 Change HeaderMap extractor to clone the headers (#698)
* 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
David Pedersen d97f2aeae6 Make TypedHeaderRejectionReason #[non_exhaustive] (#665)
* 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 (#646)
Fixes https://github.com/tokio-rs/axum/issues/636
2022-01-23 18:01:52 +01:00
David PedersenandGitHub 830bfdbe3c Change TestClient to not follow redirects (#715)
Makes it more obvious what actually goes on
2022-01-21 17:32:12 +01:00
David PedersenandGitHub 5ffab810c0 Update to changed compiler error in 1.58 (#708)
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 PedersenandGitHub 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