Commit graph

171 commits

Author SHA1 Message Date
David Pedersen
607a20dfac
Support deserialize_any for Path (#1693) 2023-01-13 12:27:38 +00:00
David Pedersen
25a46fbe79 fixup changelog 2023-01-13 11:54:30 +01:00
valkyrie_pilot
e4c6d76bca
Implement IntoResponse for [u8; N] and &'static [u8; N] (#1690)
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
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 Pedersen
be9a8c0380
Document breaking changes related to nest (#1684) 2023-01-07 19:06:59 +01:00
Paolo Barbolini
211de92d24
Enable the runtime feature of hyper when using tokio (#1671) 2023-01-06 12:28:31 +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
87a80ec47b
axum v0.6.1 (#1588) 2022-11-29 08:43:18 +00:00
LeoniePhiline
28f1996f9c
Clarify nested outer fallbacks in CHANGELOG.md (#1581) 2022-11-27 01:03:13 +01:00
David Pedersen
1b6780cf6c
axum 0.6 and friends 🎉 (#1570)
* changelog

* bump versions

* reorder changelogs a bit

* Apply suggestions from code review

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

* Expand fallback inheritance

* Reword tsr

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

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-11-25 12:29:58 +00:00
David Pedersen
0b26411f39
Change Router::with_state and impl Service for Router<()> (#1552)
* Implement `Service` for `Router<(), B>`

* wip

* wip

* fix some tests

* fix examples

* fix doc tests

* clean up docs

* changelog

* fix

* also call `with_state` when converting `MethodRouter` into a `MakeService`

* suggestions from review
2022-11-24 14:43:10 +00:00
David Pedersen
b816ac7cdf
Add RouterService::{layer, route_layer} (#1550)
* Add `RouterService::{layer, route_layer}`

Figure we might as well have these.

* changelog
2022-11-19 21:51:55 +00:00
David Pedersen
2e3000f1a3 Fix typo 2022-11-18 18:36:49 +01:00
David Pedersen
37b9b3df48 Remove duplicate changelog entry 2022-11-18 17:59:05 +01:00
David Pedersen
878ae73e6d
New release candidates (#1541) 2022-11-18 17:29:47 +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 Pedersen
ba8e9c1b21
Add on_failed_upgrade callback to WebSocketUpgrade (#1539)
* Add `on_failed_upgrade` callback to `WebSocket`

Previously if upgrading a connection to a WebSocket connection failed
the background task would panic. There was no way to customize that so
users that might wanna report the error was out of luck.

Panicking also wasn't great because users might abort on panics which
would bring down the server.

* changelog

* Apply suggestions from code review

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

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-11-18 10:53:04 +00:00
David Pedersen
7090649377
Add fallback inheritance for nested routers (#1521)
* fallback inheritance

* cleanup

* changelog
2022-11-18 10:25:04 +00:00
danielvschoor
c461f1d827
Add accept_unmasked_frames setting in WebSocketUpgrade (#1529)
* Add accept_unmasked_frames setting in WebSocketUpgrade

* Update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-11-15 09:02:12 +00:00
David Pedersen
74bbe80f8a
axum 0.6.0-rc.4 (#1518) 2022-11-09 13:49:47 +01:00
David Pedersen
028cac4a72
Fix compile error in release mode (#1517) 2022-11-09 13:36:10 +01:00
David Pedersen
1d6a96ee20 Remove references to *_with_state_arc functions from changelog
They were removed again before being released.
2022-11-09 09:27:37 +01:00
David Pedersen
e53c85c496 Minor changelog fixes 2022-11-09 09:20:09 +01:00
David Pedersen
e39d053d2f
New release candidates (#1514)
* New release candidates

* Update axum/Cargo.toml

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

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-11-09 09:01:47 +01:00
David Pedersen
0e3f9d0938
Don't allow extracting MatchedPath in middleware for nested routes (#1462)
* Don't allow extracting `MatchedPath` for nested paths

* misc clean up

* Update docs

* changelog

* Apply suggestions from code review

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

* Add test for nested handler service

* change to `debug_assert`

* apply suggestions from review

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-11-08 20:43:19 +00:00
David Pedersen
e0ef641e5f
Rework Form and Query rejections (#1496)
* Change `FailedToDeserializeQueryString` rejection for `Form`

Its now called `FailedToDeserializeForm`.

* changelog

* Make dedicate rejection type for axum-extra's `Form`

* update trybuild test

* Make dedicate rejection type for axum-extra's `Query`
2022-11-08 20:31:06 +00:00
Marek Kuskowski
bc8a507f58
Add RawForm extractor (#1487)
* Add RawForm extractor

* Change RawForm(String) to RawForm(Option<String>)

* Fix tests

* Use Bytes instead of Option<String> and add tests

* Add test for empty body

* Update CHANGELOG

* small docs tweaks

* changelog nit

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-10-20 18:03:13 +00: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
a57bd9a118 Move changelog item to "unreleased" 2022-10-04 14:25:31 +02:00
Jonas Platte
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 <david.pdrsn@gmail.com>
2022-09-28 20:20:47 +00:00
Danny
fef95bf37a
Add From impls for extract::ws::Message (#1421)
* Add From impls for extract::ws::Message

These come from tungstenite but were not exposed by axum

* Add changelog entry
2022-09-26 19:07:12 +00:00
Jonas Platte
9196c09fe8
Merge handler::{WithState, IntoService} into one HandlerService type (#1418) 2022-09-26 14:51:42 +02:00
Logan Keenan
31638a2b22
Add tokio feature & make tokio optional for WASM support (#1382)
* add server feature and make tokio and hyper/server and tcp optional

* address review comments

* don't mention any specific runtimes in the example

* sort deps

* add `tokio` feature when adding `ws`

* don't always pull in tower feature that pulls in tokio io stuff

* remove usage of `tokio_cr`

* changelog

* depend on tokio version that supports wasm

* don't make it sound like tokio doesn't support wasm

* call out new default feature

Co-authored-by: Fisher Darling <fdarlingco@gmail.com>
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-09-25 15:10:33 +00:00
David Pedersen
04ef2f1bc0
Add map_response and friends (#1414)
* Add `map_response` and friends

* changelog
2022-09-25 16:21:30 +02:00
David Pedersen
8dd9c8d286 Add missing changelog PR links 2022-09-25 14:41:15 +02:00
Jonas Platte
4847d681b1
Allow Routers to inherit state (#1368)
* Rename Fallback::Custom to Fallback::Service

* Allow Routers to inherit state

* Rename Router::{nest => nest_service} and add new nest method for Routers

* Fix lints

* Add basic tests for state inheritance

* Changelog
2022-09-25 11:56:23 +00:00
David Pedersen
2077d50021
Add map_request and friends (#1408)
* Add `map_request` and friends

* finish it

* changelog ref

* Apply suggestions from code review

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

* address review feedback

* Apply suggestions from code review

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

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-09-25 11:44:10 +00:00
Marek Kuskowski
896ffc5fba
Remove ContentLengthLimit (#1400)
* feat: remove ContentLengthLimit

* feat: remove ContentLengthLimit rejections

* fix: update multipart docs

* fix: typo

* feat: add wip extractor code

* feat: revert "feat: add wip extractor code"

* fix: update Multipart docs

* fix: update examples

* fix: missing import in an example

* fix: broken import yet again

* fix: disable default body limit for example

* fix: key value store example

* fix: update expected debug_handler output

* chore: update CHANGELOG

* Update axum/CHANGELOG.md

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-09-24 11:29:53 +00:00
David Pedersen
611c50ec8b
Add middleware::from_extractor_with_state (#1396)
Fixes https://github.com/tokio-rs/axum/issues/1373
2022-09-20 10:13:06 +02:00
David Pedersen
de9909d955
Add DefaultBodyLimit::max to change the body size limit (#1397) 2022-09-19 22:41:54 +02:00
David Pedersen
c81549d95b
Support streaming/chunked requests in ContentLengthLimit (#1389)
* Support streaming/chunked requests in `ContentLengthLimit`

* changelog
2022-09-18 20:21:38 +00:00
David Pedersen
8e52c5246f
Use 400 Bad Request for FailedToDeserializeQueryString rejections (#1387)
* Use `400 Bad Request` for `FailedToDeserializeQueryString` rejections

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

From [the spec] about `422 Unprocessable Entity`:

> For example, this error condition may occur if an XML request body
> contains well-formed (i.e., syntactically correct), but semantically
> erroneous, XML instructions.

I understand this to mean that query params shouldn't use 422 because
that is about the request body.

So this changes `FailedToDeserializeQueryString` from `422 Unprocessable
Entity` to `400 Bad Request`.

[the spec]: https://datatracker.ietf.org/doc/html/rfc4918#section-11.2

* changelog
2022-09-18 21:32:47 +02:00
Ferenc Tamás
84f58ae9a5
expose FromRequest and FromRequestParts macros in axum (#1352) 2022-09-18 19:46:04 +02:00
Hong Minhee (洪 民憙)
7476dd08cb
Show the errored path on JsonDataError (#1371)
Previously, it was difficult to find out the path in the deep JSON tree at
which a deserialization error occurred.  This patch makes an error message
to contain the errored path.  In order to find out the path,
I added serde_path_to_error, a new optional dependency.

Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>

Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>
2022-09-13 17:52:16 +02:00
David Pedersen
54d8439e35
Ship rc.2 (#1363)
* rc.2

* don't bump version of axum-macros

* fix

* Update axum/Cargo.toml

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

* undo release of axum-extra

* fix

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
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
David Pedersen
4c9edb4cd4
Add middleware::{from_fn_with_state, from_fn_with_state_arc} (#1342) 2022-08-31 18:28:54 +00:00
Jonas Platte
92f6b68390
Panic when attempting to add a route_layer to an empty router (#1327) 2022-08-25 15:42:17 +02:00
Yann Simon
426b9f91e8
FromRequestParts does not have a 'B' type (#1315) 2022-08-24 09:56:02 +00:00