Commit Graph
81 Commits
Author SHA1 Message Date
Spencer Bartholomew 6067223fcc update tokio dep to fix potential security vulnerability (#1787) 2023-02-27 18:40:03 +01:00
David Pedersen f726f16b6d Update to tower-http 0.4 (#1783) 2023-02-24 20:51:30 +00:00
David Pedersen e6ff0281ae Try cargo public-api-crates on CI (#1761) 2023-02-16 22:41:41 +01:00
David Pedersen 6ff6b36293 Release axum and axum-core (#1716) 2023-01-20 23:51:19 +01:00
David Pedersen 25a46fbe79 fixup changelog 2023-01-13 11:54:30 +01:00
valkyrie_pilotandDavid Pedersen e4c6d76bca Implement IntoResponse for [u8; N] and &'static [u8; N] (#1690)
Co-authored-by: David Pedersen <[email protected]>
2023-01-13 09:12:51 +00:00
David Pedersen e3aaeb3cb7 Release axum, axum-core, and axum-macros (#1688) 2023-01-09 13:54:49 +01:00
David PedersenandJonas Platte 1aa357c879 Misc documentation improvements (#1647)
Co-authored-by: Jonas Platte <[email protected]>
2023-01-07 14:07:54 +01:00
David Pedersen 7e13d69639 Add status and body_text methods to built-in rejections (#1612)
* Add `status` and `body_text` methods to built-in rejections

This should make it easier to customize a built-in rejection while
preserving either the status or body.

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

* changelog
2022-12-02 19:54:16 +01:00
David Pedersen eb2e933054 Expand the docs for Router::with_state (#1580) 2022-11-27 01:01:59 +01:00
David PedersenandJonas Platte 1b6780cf6c axum 0.6 and friends 🎉 (#1570)
* changelog

* bump versions

* reorder changelogs a bit

* Apply suggestions from code review

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

* Expand fallback inheritance

* Reword tsr

* Mention `parse-body-based-on-content-type` example

Co-authored-by: Jonas Platte <[email protected]>
2022-11-25 12:29:58 +00:00
Tshepang Mbambo 3ab3e5f91d Use http re-export in docs (#1554) 2022-11-20 21:48:41 +01:00
d5de3bc7e3 Improve compile errors for unimplemented traits (#1436)
* Improve `debug_handler` to use the correct span for specific bounds

This results in better localised error messages, as they now point
directly to the corresponding argument instead of to the macro itself.

* Improve some error messages behind a `nightly-error-messages` feature
flag

This uses the nightly only `rustc_on_unimplemented` attribute to improve
some error messages when users try to use invalid handler functions.
This should be seen as prove of concept, not as full solution for all
potential error cases.

The underlying feature is currently marked as permanently unstable, but
I'm working on getting this specific attribute (or an attribute with
different name, similar functionality) ready to work on a stable compiler.

* Apply suggestions from code review

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

* Enable the `nightly-error-messages` feature unconditionally for nightly compilers

* Use a nightly compiler to run the axum-marcos compile fail tests

* update to newer nightly

* Run axum-macros tests on nightly

* tweak compile error hints a bit

* more tweaks

* update test

Co-authored-by: Jonas Platte <[email protected]>
Co-authored-by: David Pedersen <[email protected]>
2022-11-19 12:45:03 +01:00
David Pedersen 64960bb19c Type safe state inheritance (#1532)
* Make state type safe

* fix examples

* remove unnecessary `#[track_caller]`s

* Router::into_service -> Router::with_state

* fixup docs

* macro docs

* add missing docs

* fix examples

* format

* changelog

* Update trybuild tests

* Make sure fallbacks are still inherited for opaque services (#1540)

* Document nesting routers with different state

* fix leftover conflicts
2022-11-18 11:02:58 +00:00
David PedersenandJonas Platte e39d053d2f New release candidates (#1514)
* New release candidates

* Update axum/Cargo.toml

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

Co-authored-by: Jonas Platte <[email protected]>
2022-11-09 09:01:47 +01:00
David Pedersen 958d360ac4 Generalize AppendHeaders to accept any impl IntoIterator (#1495)
* Generalize `AppendHeaders` to accept any `impl IntoIterator`

* changelog
2022-10-20 21:05:04 +02:00
Jonas Platte b378fb283f Add Error::into_inner (#1476) 2022-10-13 11:44:54 +02:00
David Pedersen 9c0a89cd09 Add #[derive(FromRef)] (#1430)
* add `#[derive(FromRef)]`

* tests

* don't support skipping fields

probably wouldn't work at all since the whole state likely needs `Clone`

* UI tests

* changelog

* changelog link

* revert hello-world example, used for testing

* Re-export `#[derive(FromRef)]`

* Don't need to return `Result`

* use `collect` instead of quoting the iterator

* Mention it in axum's changelog
2022-10-10 18:40:14 +00:00
David Pedersen 1681ecf438 Copy changelogs from 0.5.x branch 2022-10-10 20:23:11 +02:00
David Pedersen 70833b9f4f Document differences between DefaultBodyLimit and RequestBodyLimit (#1461)
* Document differences between `DefaultBodyLimit` and `RequestBodyLimit`

* fix grammar

* fix accidental force push
2022-10-10 17:43:05 +02:00
Jonas PlatteandDavid Pedersen b94248191e Add RequestExt::{with_limited_body, into_limited_body} (#1420)
* Move RequestExt and RequestPartsExt into axum-core

* Add RequestExt::into_limited_body

… and use it for Bytes extraction.

* Add RequestExt::with_limited_body

… and use it for Multipart extraction.

Co-authored-by: David Pedersen <[email protected]>
2022-09-28 20:20:47 +00:00
David Pedersen bf341fd034 Refactor all_the_tuples! macros (#1413) 2022-09-25 15:22:40 +02:00
David Pedersen de9909d955 Add DefaultBodyLimit::max to change the body size limit (#1397) 2022-09-19 22:41:54 +02:00
David PedersenandJonas Platte 54d8439e35 Ship rc.2 (#1363)
* rc.2

* don't bump version of axum-macros

* fix

* Update axum/Cargo.toml

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

* undo release of axum-extra

* fix

Co-authored-by: Jonas Platte <[email protected]>
2022-09-11 16:42:04 +02:00
David Pedersen 759e988747 Limit size of request bodies in Bytes extractor (#1346)
* Apply default limit to request body size

* Support disabling the default limit

* docs

* changelog
2022-09-10 06:36:30 +00:00
Liigo Zhuang f8683f37f8 Fix broken docs links (#1332) 2022-08-26 09:30:38 +00:00
David Pedersen b315b60bca Bump version of all crates (#1310)
* Bump version of all crates

* use the right versions inside the workspace
2022-08-23 22:57:13 +02:00
David PedersenandJonas Platte be624306f4 Only allow last extractor to mutate the request (#1272)
* Only allow last extractor to mutate the request

* Change `FromRequest` and add `FromRequestParts` trait (#1275)

* Add `Once`/`Mut` type parameter for `FromRequest` and `RequestParts`

* 🪄

* split traits

* `FromRequest` for tuples

* Remove `BodyAlreadyExtracted`

* don't need fully qualified path

* don't export `Once` and `Mut`

* remove temp tests

* depend on axum again

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

* Port `Handler` and most extractors (#1277)

* Port `Handler` and most extractors

* Put `M` inside `Handler` impls, not trait itself

* comment out tuples for now

* fix lints

* Reorder arguments to `Handler` (#1281)

I think `Request<B>, Arc<S>` is better since its consistent with
`FromRequest` and `FromRequestParts`.

* Port most things in axum-extra (#1282)

* Port `#[derive(TypedPath)]` and `#[debug_handler]` (#1283)

* port #[derive(TypedPath)]

* wip: #[debug_handler]

* fix #[debug_handler]

* don't need itertools

* also require `Send`

* update expected error

* support fully qualified `self`

* Implement FromRequest[Parts] for tuples (#1286)

* Port docs for axum and axum-core (#1285)

* Port axum-extra (#1287)

* Port axum-extra

* Update axum-core/Cargo.toml

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

* remove `impl FromRequest for Either*`

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

* New FromRequest[Parts] trait cleanup (#1288)

* Make private module truly private again

* Simplify tuple FromRequest implementation

* Port `#[derive(FromRequest)]` (#1289)

* fix tests

* fix docs

* revert examples

* fix docs link

* fix intra docs links

* Port examples (#1291)

* Document wrapping other extractors (#1292)

* axum-extra doesn't need to depend on axum-core (#1294)

Missed this in https://github.com/tokio-rs/axum/pull/1287

* Add `FromRequest` changes to changelogs (#1293)

* Update changelog

* Remove default type for `S` in `Handler`

* Clarify which types have default types for `S`

* Apply suggestions from code review

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

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

* remove unused import

* Rename `Mut` and `Once` (#1296)

* fix trybuild expected output

Co-authored-by: Jonas Platte <[email protected]>
2022-08-22 12:23:20 +02:00
David Pedersen f1769e5134 Re-organize changelog to make updating to 0.6 easier (#1274) 2022-08-20 21:11:02 +02:00
David Pedersen e7f1c88cd4 Always store state in an Arc (#1270)
* Add extension and state benchmarks

* wip

* Arc the state everywhere

* don't require `S: Clone`

* fix example
2022-08-17 20:08:24 +00:00
423308de3c Add type safe state extractor (#1155)
* begin threading the state through

* Pass state to extractors

* make state extractor work

* make sure nesting with different states work

* impl Service for MethodRouter<()>

* Fix some of axum-macro's tests

* Implement more traits for `State`

* Update examples to use `State`

* consistent naming of request body param

* swap type params

* Default the state param to ()

* fix docs references

* Docs and handler state refactoring

* docs clean ups

* more consistent naming

* when does MethodRouter implement Service?

* add missing docs

* use `Router`'s default state type param

* changelog

* don't use default type param for FromRequest and RequestParts

probably safer for library authors so you don't accidentally forget

* fix examples

* minor docs tweaks

* clarify how to convert handlers into services

* group methods in one impl block

* make sure merged `MethodRouter`s can access state

* fix docs link

* test merge with same state type

* Document how to access state from middleware

* Port cookie extractors to use state to extract keys (#1250)

* Updates ECOSYSTEM with a new sample project (#1252)

* Avoid unhelpful compiler suggestion (#1251)

* fix docs typo

* document how library authors should access state

* Add `RequestParts::with_state`

* fix example

* apply suggestions from review

* add relevant changes to axum-extra and axum-core changelogs

* Add `route_service_with_tsr`

* fix trybuild expectations

* make sure `SpaRouter` works with routers that have state

* Change order of type params on FromRequest and RequestParts

* reverse order of `RequestParts::with_state` args to match type params

* Add `FromRef` trait (#1268)

* Add `FromRef` trait

* Remove unnecessary type params

* format

* fix docs link

* format examples

* Avoid unnecessary `MethodRouter`

* apply suggestions from review

Co-authored-by: Dani Pardo <[email protected]>
Co-authored-by: Jonas Platte <[email protected]>
2022-08-17 15:13:31 +00:00
Jonas Platte 141198ce19 Declare MSRV in Cargo manifests, not .clippy.toml (#1206) 2022-07-28 15:31:47 +02:00
Dominik Spicher bc55362ba8 Fix typos in RequestParts docstrings (#1147) 2022-07-08 13:26:34 +00: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 5ac0b2b3d7 axum: Version 0.5.8 (#1104) 2022-06-18 11:38:52 +02:00
David Pedersen 7deaff7e1e axum-core: Version 0.2.6 (#1103) 2022-06-18 11:00:19 +02:00
Jonas Platte 1812c4dfe8 Remove explicit TryFrom, TryInto imports (#1099) 2022-06-17 18:36:49 +00: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 968ee44631 Sort dependencies in Cargo.tomls (#1076)
* sort dependencies

* check sorted deps on CI

* this should fail

* does caching matter?

* fix sorting
2022-06-10 08:59:17 +02:00
David Pedersen a9eb4ac527 axum-core: Version 0.2.5 (#1073) 2022-06-08 15:56:56 +02:00
David Pedersen ef750799fa Automatically handle http_body::LengthLimitError (#1048)
* Automatically handle `http_body::LengthLimitError`

* add tower-http dev dep to axum-core

* just make it a link

* Make `FailedToBufferBody` an enum

* Fix tests now that tower-http handles `Content-Length`

* Bring back explanation for `LengthLimitError`

* remove todo we likely can't fix

* improve wording in docs
2022-06-08 13:47:57 +00: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
David Pedersen 5be73c1064 axum-core: Version 0.2.4 (#984) 2022-05-02 11:52:24 +02:00
David Pedersen 8dd6070574 Implement IntoResponse for (Parts | Request<()>, $(impl IntoResponseParts)+, impl IntoResponse) (#980)
* Implement `IntoResponse for (Parts | Request<()>, $(impl IntoResponseParts)+, impl IntoResponse)`

Fixes #979

* changelog

* docs

* changelog ref
2022-04-29 22:08:47 +02:00
Marcus GriepandDavid Pedersen 6e1835074c Implement IntoResponse for Response<()> and response::Parts (#950)
* feat(axum-core): add IntoResponse for `http::response` types

* chore: narrow impl to `Response<()>`

* include extensions

* changelog

Co-authored-by: David Pedersen <[email protected]>
2022-04-29 17:52:21 +02:00
David Pedersen 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 Pedersen 0702c59c7d axum-core: Version 0.2.3 (#966) 2022-04-26 14:19:47 +00:00
8084b242d5 Add response::ErrorResponse and response::Result (#921)
* feat: add response::{Error, Result}

This type makes for efficient use of the `?` operator when in a function
with multiple return error types that all implement `IntoResponse`.

Signed-off-by: Nathaniel McCallum <[email protected]>

* misc adjustments from PR review

* Rename to `ErrorResponse` and `ResultResponse`

* nitpicky docs changes

* update changelog

* changelog wording

* Apply suggestions from code review

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

Co-authored-by: David Pedersen <[email protected]>
Co-authored-by: Jonas Platte <[email protected]>
2022-04-21 16:24:29 +02:00
David Pedersen 598e6935df axum-core: Version 0.2.2 2022-04-19 16:17:52 +02:00