axum/examples
David Pedersen 8013165908
Move methods from ServiceExt to RoutingDsl (#160)
Previously, on `main`, this wouldn't compile:

```rust
let app = route("/", get(handler))
    .layer(
        ServiceBuilder::new()
            .timeout(Duration::from_secs(10))
            .into_inner(),
    )
    .handle_error(...)
    .route(...); // <-- doesn't work
```

That is because `handle_error` would be
`axum::service::ServiceExt::handle_error` which returns `HandleError<_,
_, _, HandleErrorFromService>` which does _not_ implement `RoutingDsl`.
So you couldn't call `route`. This was caused by
https://github.com/tokio-rs/axum/pull/120.

Basically `handle_error` when called on a `RoutingDsl`, the resulting
service should also implement `RoutingDsl`, but if called on another
random service it should _not_ implement `RoutingDsl`.

I don't think thats possible by having `handle_error` on `ServiceExt`
which is implemented for any service, since all axum routers are also
services by design.

This resolves the issue by removing `ServiceExt` and moving its methods
to `RoutingDsl`. Then we have more tight control over what has a
`handle_error` method.

`service::OnMethod` now also has a `handle_error` so you can still
handle errors from random services, by doing
`service::any(svc).handle_error(...)`.
2021-08-08 14:30:51 +02:00
..
async-graphql Replace hyper::Server with axum::Server in docs (#118) 2021-08-04 15:38:51 +02:00
chat Add chat example (#78) 2021-08-01 22:42:34 +02:00
self_signed_certs Add TLS example (with rustls) (#57) 2021-08-01 08:32:47 +02:00
sse Server-Sent Events (#75) 2021-08-01 21:49:17 +02:00
templates Add HTML template example (#17) 2021-06-13 13:58:12 +02:00
websocket Add support for websockets (#3) 2021-06-12 20:50:30 +02:00
404.rs Handle METHOD_NOT_ALLOWED in 404 example (#131) 2021-08-06 01:15:23 +02:00
chat.rs Make ws::Message an enum for easier frame type matching (#116) 2021-08-07 19:47:22 +02:00
error_handling_and_dependency_injection.rs Support returning any http_body::Body from IntoResponse (#86) 2021-08-07 18:03:21 +02:00
form.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
hello_world.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
key_value_store.rs Move methods from ServiceExt to RoutingDsl (#160) 2021-08-08 14:30:51 +02:00
multipart_form.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
README.md Add dedicated tracing/logging example (#155) 2021-08-07 22:11:55 +02:00
sessions.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
sse.rs Move methods from ServiceExt to RoutingDsl (#160) 2021-08-08 14:30:51 +02:00
static_file_server.rs Move methods from ServiceExt to RoutingDsl (#160) 2021-08-08 14:30:51 +02:00
templates.rs Support returning any http_body::Body from IntoResponse (#86) 2021-08-07 18:03:21 +02:00
testing.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
tls_rustls.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
todos.rs Move methods from ServiceExt to RoutingDsl (#160) 2021-08-08 14:30:51 +02:00
tokio_postgres.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
tracing_aka_logging.rs Add dedicated tracing/logging example (#155) 2021-08-07 22:11:55 +02:00
unix_domain_socket.rs Simplify tracing-subscriber initialization (#128) 2021-08-05 19:43:03 +02:00
versioning.rs Support returning any http_body::Body from IntoResponse (#86) 2021-08-07 18:03:21 +02:00
websocket.rs Move methods from ServiceExt to RoutingDsl (#160) 2021-08-08 14:30:51 +02:00

Examples

Community showcase

  • Houseflow: House automation platform written in Rust.