Commit Graph
554 Commits
Author SHA1 Message Date
David Pedersen 4562cf3f26 axum: Version 0.4.8
- Use correct path for `AddExtensionLayer` and `AddExtension::layer` deprecation
  notes ([#812])

[#812]: https://github.com/tokio-rs/axum/pull/812
axum-v0.4.8
2022-03-02 13:48:56 +01:00
Jonathan Johnson d083d7f125 Using fully qualified path for Extension (#812)
When updating code this morning, I initially stumbled as I tried to use
`axum::Extension`, but was met with an error. After going to the docs, I
saw that Extension isn't exported at the top level.
2022-03-01 17:49:10 +01:00
David Pedersen 87638d07cf axum-macros: Version 0.1.2
- **fixed:** Use fully qualified `Result` type ([#796])

[#796]: https://github.com/tokio-rs/axum/pull/796
axum-macros-v0.1.2
2022-03-01 14:21:45 +01:00
David Pedersen ca8a6c08c2 axum-extra: Version 0.1.5
- **added:** Add `TypedPath::to_uri` for converting the path into a `Uri` ([#790])

[#790]: https://github.com/tokio-rs/axum/pull/790
axum-extra-v0.1.5
2022-03-01 14:19:20 +01:00
David PedersenandMatthias Vogelgesang 84cbb66575 Backport TypedPath::to_uri (#809)
* axum-macros: use fully qualified Result type (#796)

* 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

* Remove out of date docs

These accidentally weren't removed in https://github.com/tokio-rs/axum/pull/790

Co-authored-by: Matthias Vogelgesang <[email protected]>
2022-03-01 14:17:17 +01:00
David Pedersen 558a4d05b0 axum: Version 0.4.7 (#808)
- **added:** Implement `tower::Layer` for `Extension` ([#801])
- **changed:** Deprecate `AddExtensionLayer`. Use `Extension` instead ([#805])

[#801]: https://github.com/tokio-rs/axum/pull/801
[#805]: https://github.com/tokio-rs/axum/pull/805
axum-v0.4.7
2022-03-01 13:59:52 +01:00
David Pedersen ee387ae30b Backport impl tower::Layer for Extension (#805)
* Implement `tower::Layer` for `Extension` (#801)

* Implement `tower::Layer` for `Extension`

* changelog

* Deprecate `AddExtensionLayer`

* changelog

* Add missing #[allow(deprecated)]
2022-03-01 12:05:42 +01:00
David Pedersen 5cb6e6d16e Update trybuild test 2022-03-01 11:59:15 +01:00
David Pedersen 36da5fceab axum-extra: Version 0.1.4 axum-extra-v0.1.4 2022-02-22 15:05:53 +01:00
David Pedersen ed877820ce Fix dependency versions in axum-extra (#782)
Updating to axum-extra 0.1.3 might cause the build to fail if axum
wasn't also updated, since axum-extra 0.1.3 needs
`axum::middleware::from_fn`.

This fixes that by depending on the right patch versions for axum and
axum-macros.
2022-02-22 15:04:45 +01:00
David Pedersen aa4ab8b084 axum-extra: Version 0.1.3 axum-extra-v0.1.3 2022-02-22 13:59:46 +01:00
David Pedersen b2267be2d5 axum-macros: Version 0.1.1 axum-macros-v0.1.1 2022-02-22 13:56:52 +01:00
David Pedersen 4b0b4c8772 axum: Version 0.4.6 (#780) axum-v0.4.6 2022-02-22 13:53:29 +01:00
David Pedersen 263e58e2c3 axum-core: Version 0.1.2 axum-core-v0.1.2 2022-02-22 13:43:57 +01:00
David Pedersen 9c47131d90 Make module name consistent with tower 2022-02-22 13:33:10 +01:00
David Pedersen 8c6c736d3d Allow duplicate tokio-util dependency for now
Requires a new release of h2 to fix
2022-02-22 13:33:10 +01:00
David Pedersen 25bb9ac3ea fully remove the axum-debug directory
not sure why it wasn't removed by the earlier commits. Probably because
of the order I cherry-picked in.
2022-02-22 13:33:10 +01:00
David Pedersen 943f6ba38e don't list empty default feature, its a noop 2022-02-22 13:33:10 +01:00
Clayton Faria 26a4a7bc0a fix typo in the docs (#774) 2022-02-22 13:33:10 +01:00
David PedersenandJonas Platte c298c36577 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-22 13:33:10 +01:00
David Pedersen 00553a32c4 Remove axum-debug code (#740) 2022-02-22 13:33:10 +01:00
David PedersenandJonas Platte 5e9bed4a60 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-02-22 13:33:10 +01:00
David PedersenandJonas Platte 3d2f4e4a35 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-02-22 13:33:10 +01:00
David PedersenandJonas Platte 28832ad8b1 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-02-22 13:33:10 +01:00
Olivier PinonandDavid Pedersen 5d24e5b6b6 Add IntoResponse impl for BytesMut and Chain (#767)
* Add IntoResponse impl for BytesMut and Chain

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

* Add CHANGELOG entry

Co-authored-by: David Pedersen <[email protected]>
2022-02-22 13:33:10 +01:00
Jonas Platte 2e83dff4d1 Fix doc(cfg)s (#765)
* Use automatic doc(cfg) attributes where possible

* Add missing feature documentation

* Replace redundant cfg attribute with doc(cfg)

* Remove non-existent feature from package.metadata.playground.features

* Add missing cfg's on rejection types
2022-02-22 13:33:10 +01:00
David Pedersen 9e05351d8f Fix broken docs link 2022-02-22 13:33:10 +01:00
zys864 db2c8b1489 remove unused tokio-util dependency (#758) 2022-02-22 13:33:10 +01:00
David Pedersen 3238174b1c Update dependencies (#753) 2022-02-22 13:33:10 +01:00
David Pedersen 9bffd9d0db Fix rejection status codes (#751) 2022-02-22 13:33:10 +01:00
Ibraheem Ahmed ee9e522367 update matchit to 0.4.6 (#736) 2022-02-22 13:33:10 +01:00
David Pedersen 370e67c6ce MethodRouter::fallback docs follow up
https://github.com/tokio-rs/axum/pull/733#discussion_r795244092
2022-02-22 13:33:10 +01:00
David Pedersen 31c713288e Set Allow header when returning 405 Method Not Allowed (#733) 2022-02-22 13:33:10 +01:00
David PedersenandJonas Platte 0a98230aa5 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-02-22 13:33:10 +01:00
David Pedersen 0b987c45c7 Re-export middleware::from_fn from axum-extra to avoid making breaking changes 2022-02-22 13:33:10 +01:00
David Pedersen 6d821d2a23 Move middleware::from_fn into axum (#719)
* Move `middleware::from_fn` into axum

* changelog

* fix feature

* Rephrase changelog a bit
2022-02-22 13:33:10 +01:00
Aaron Erhardt 340948c337 Fix path route in extractor docs (#711) 2022-02-22 13:33:10 +01:00
David Pedersen d3357ad94a 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-02-22 13:33:10 +01:00
David Pedersen cab7d671ba axum: Version 0.4.5 (#739) axum-v0.4.5 2022-01-31 22:28:47 +01:00
David Pedersen e3364bc7f0 Reference axum-macros instead of axum-debug (#738)
* Reference axum-macros instead of axum-debug

* changelog
2022-01-31 22:22:41 +01:00
David Pedersen 5fe981a1da axum: Version 0.4.4 (#706)
- **fixed:** Fix using incorrect path prefix when nesting `Router`s at `/` ([#691])
- **fixed:** Make `nest("", service)` work and mean the same as `nest("/", service)` ([#691])
- **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 ([#682])

[#691]: https://github.com/tokio-rs/axum/pull/691
[#682]: https://github.com/tokio-rs/axum/pull/682
axum-v0.4.4
2022-01-13 10:37:33 +01:00
Nick Ashley 007a0e85f2 Use 308 instead of 301 for trailing slash redirects (#682)
* 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 #681

* 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 (#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