Commit graph

1096 commits

Author SHA1 Message Date
David Pedersen
468985373a
Add example of how to test WebSockets (#1535) 2022-11-18 15:40:21 +01:00
David Pedersen
7d58d49817
Add #[from_ref(skip)] (#1537)
For skipping individual fields.
2022-11-18 12:05:10 +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
David Pedersen
2e8a7e51a1
Fix Handler::with_state not working if request body was changed via layer (#1536)
Previously

```rust
handler.layer(RequestBodyLimitLayer::new(...)).with_state(...)
```

didn't work because we required the same request body all the way
through.
2022-11-18 11:00:52 +01:00
David Pedersen
b1f894a500 Fix unused import if compiling with default features 2022-11-18 00:22:11 +01: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
Taylor Everding
587435940b
Add more tests for the Allow header when returning 405 (#1526)
Refs: #1525, #733
2022-11-14 16:02:05 +01:00
BBaoVanC
370ad07e75
Remove debug_assert in matched_path (#1527) 2022-11-13 02:54:29 +00:00
Kirk Paradis
afa13006cf
Update link to rust on nails (#1524) 2022-11-12 14:45:18 +01:00
Jonas Platte
c3fa0b2a3e
Fix unused variable warning when developing using a nightly toolchain (#1520) 2022-11-10 12:41:16 +01: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
9c804d506e Update changelog for axum-extra 2022-11-08 21:45:05 +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
Konstantin Kostiuk
8d6313afa0
Add example of static-file-server using serve dir with handler as service (#1501)
* add example of static-file-seriver using serve dit with handler as service

* update handle return type in example

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>

* cargo fmt fix

* change error mapping

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-11-08 20:40:20 +01:00
Jonas Platte
944f388ae0 Add missing cfg's for signed cookie tests 2022-11-05 11:33:27 +01:00
Jonas Platte
36f24990c8 Fix clippy lints 2022-11-05 11:33:27 +01:00
Jonas Platte
21475f94ff Adjust renamed clippy lint name 2022-11-05 11:33:27 +01:00
David Pedersen
a27bd2c6a2
Update trybuild tests for Rust 1.65.0 (#1509) 2022-11-04 09:07:57 +01:00
Uros
2aadf4bfd0
ECOSYSTEM.md: mention lishuuro.org (#1502) 2022-10-25 09:37:21 +00:00
David Pedersen
b59c7a8c84
Add example for Router::inherit_state (#1492)
* Add example for `Router::inherit_state`

* clarification

* Update axum/src/routing/mod.rs

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

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-10-20 19:19:05 +00: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
David Pedersen
4979b4c9b6 Implement Form in terms of RawForm 2022-10-20 20:55:11 +02: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
Jonas Platte
beb5ebbe8a
Update deny.toml (#1488) 2022-10-20 16:51:52 +02:00
David Pedersen
7caa4a3a47 Link to fork of realworld-axum-sqlx 2022-10-14 23:42:58 +02:00
Jonas Platte
b378fb283f
Add Error::into_inner (#1476) 2022-10-13 11:44:54 +02:00
David Pedersen
199a7a66b8
Expand static file serving example (#1471) 2022-10-11 07:42:48 +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
d7ba0b1d72
Relax bounds for FromExtractor (#1469)
Fixes #1467

We didn't actually use the bounds. I guess they were left over from a
previous version.
2022-10-10 16:39:16 +00: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
David Pedersen
7420721f4d
Document RouterService (#1465)
Not sure what else there is to say :P

Fixes https://github.com/tokio-rs/axum/issues/1401
2022-10-10 00:23:11 +02:00
David Pedersen
b607ad5823
Improve map_response docs (#1464)
* Document when extractors run

* Document returning `impl IntoResponse`
2022-10-09 23:33:22 +02:00
David Pedersen
f9dc96fdce
Don't internally Arc the state (#1460) 2022-10-09 20:55:28 +00:00
Jonas Platte
a2ab338e68
Rewrite how state is passed from Router to MethodRouter 2022-10-09 19:33:40 +00:00
Jonas Platte
7cbacd1433
Improve the error message for state type inference failure in FromRequest(Parts) derive macro (#1432)
* Add a dedicated error message for state type inference issues

* Generate valid code even if state type can't be inferred

* Also error on state type inference for debug_handler
2022-10-09 20:25:05 +02:00
Valentin Brandl
ee0b71a4ac
Start second server on different port for metrics endpoint (#1444)
* Start second server on different port for metrics endpoint

* Don't track metrics on metrics server
2022-10-08 01:28:32 +02:00
Jonas Platte
a7d8954178
Use RequestPartsExt more in docs / examples (#1445)
* Use RequestPartsExt more in docs / examples

* Remove unused import
2022-10-04 17:26:51 +00:00
David Pedersen
a57bd9a118 Move changelog item to "unreleased" 2022-10-04 14:25:31 +02:00
Horu
a3c58a18ed
Fix typo in example (#1439) 2022-10-01 13:49:15 +00: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
Marek Barvíř
be54583d98
Reexport key-expansion (#1425)
* Reexport key-expansion

* Description

Co-authored-by: Marek Barvíř <barvir@cadwork.cz>
2022-09-28 20:06:56 +00:00
Jonas Platte
410fd49aa9
Fix Cached<T> as the last argument of a handler function (#1428)
* Remove FromRequest impl for Cached<T>

* Add a test for Cached<T> as the last argument of a handler function
2022-09-28 09:06:15 +00:00