* feat(ws): make Message an enum to allow pattern matching
* fix(examples): update to new websockets `Message`
* fix(ws): remove wildcard imports
* fix(examples/chat): apply clippy's never_loop
* style: `cargo fmt`
* docs:add license notes above parts that are copied
* fix(ws): make CloseCode an alias to u16
* fix: move Message from src/ws/mod.rs to src/extract/ws.rs
* docs: add changelog entry about websocket messages
* fix: remove useless convertions to the same type
Adds associated `Body` and `BodyError` types to `IntoResponse`. This is required for returning responses with bodies other than `hyper::Body` from handlers. That wasn't previously possible.
This is a breaking change so should be shipped in 0.2.
With this you'll be able to do:
```rust
let one = route("/foo", get(|| async { "foo" }))
.route("/bar", get(|| async { "bar" }));
let two = route("/baz", get(|| async { "baz" }));
let app = one.or(two);
```
Fixes https://github.com/tokio-rs/axum/issues/101
As described in
https://github.com/tokio-rs/axum/pull/108#issuecomment-892811637, a
`HandleError` created from `axum::ServiceExt::handle_error` should _not_
implement `RoutingDsl` as that leads to confusing routing behavior.
The technique used here of adding another type parameter to
`HandleError` isn't very clean, I think. But the alternative is
duplicating `HandleError` and having two versions, which I think is less
desirable.
These types were moved around in
https://github.com/tokio-rs/axum/pull/130 but re-export from their old
location for backwards compatibility.
This removes the re-exports.
https://github.com/tokio-rs/axum/pull/129 was a breaking change, in part
because I had to remove the `Copy` impl from `OnMethod`.
For the sake of future proofing I think we should remove other `Copy`
impls from services as well. We can always bring them back once things
have matured more.
These types no longer implement `Copy`:
- `EmptyRouter`
- `ExtractorMiddleware`
- `ExtractorMiddlewareLayer`
* Feature-gate test that depends on non-default features
Makes `cargo check` work without extra flags.
* Don't set doc(html_root_url)
It is no longer recommended:
https://github.com/rust-lang/api-guidelines/pull/230
* Remove documentation URL from Cargo.toml
crates.io will link to the right version on docs.rs automatically.
* Ensure toolchains installed by actions-rs/toolchain are actually used
* Fix missing rustup component in check job
* Raise MSRV to 1.51
Older versions weren't actually working before.
* Only run clippy & rustfmt on stable toolchain
MSRV is checked in test-versions.
* Allow cargo doc to succeed without headers and multipart features
CI will still ensure that intra-doc links that rely on these are not broken.
It cleans up the docs to have the futures in their own modules as users
are unlikely to look at them. Also matches the pattern used in tower
https://docs.rs/tower/0.4.8/tower/util/future/index.html.
Added re-exports to the old locations so its not a breaking change.
* Set RUST_LOG environment var for all examples using tracing
Signed-off-by: Spencer Gilbert <spencer.gilbert@gmail.com>
* Update examples/multipart_form.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This breaks up `extract.rs` into several smaller submodules. The public
API remains the same.
This is done in prep for adding more tests to extractors which would get
messy if they were all in the same file.