Commit Graph
23 Commits
Author SHA1 Message Date
David Pedersen 2322d39800 Add StreamBody (#237)
This adds `StreamBody` which converts a `Stream` of `Bytes` into a `http_body::Body`.

---

As suggested by Kestrer on Discord it would make sense for axum to provide different kinds of body types other than `Empty`, `Full`, and `hyper::Body`. There is also some talk about [splitting up `hyper::Body`](https://github.com/hyperium/hyper/issues/2345) so this can be seen as getting started on that effort. axum's body types could be moved to hyper or http-body if thats the direction we decide on.

The types I'm thinking about adding are:

- `StreamBody`-  added in this PR
- `AsyncReadBody` - similar to [http-body#41](https://github.com/hyperium/http-body/pull/41/files)
- `ChannelBody` - similar to `hyper::Body::channel`
2021-08-22 14:41:51 +02:00
David Pedersen f8a0d81d79 Remove tower from axum's public API (#229)
Instead rely on `tower-service` and `tower-layer`. `tower` itself is
only used internally.

Fixes https://github.com/tokio-rs/axum/issues/186
2021-08-21 15:01:30 +02:00
David Pedersen b75b7b0184 Re-export more body utilities (#162)
Useful when implementing `IntoResponse`
2021-08-08 16:41:17 +02:00
David Pedersen a38d5c3592 Re-export http_body::Body (#152)
Makes writing `IntoResponse` impls easier
2021-08-07 20:29:24 +02:00
David Pedersen 75b5615ccd Add axum::Error (#150)
Replace `BoxStdError` and supports downcasting
2021-08-07 19:56:44 +02:00
David Pedersen 3d45a97db9 Make FromRequest default to use axum::body::Body (#146)
Most users will implement `FromRequest<axum::body::Body>` so making that
the default makes things a bit easier to use.
2021-08-07 12:22:14 +02:00
David Pedersen f581e3efb2 Clarify required response body type when routing to tower::Services (#69) 2021-08-01 15:42:12 +02:00
David Pedersen f32d325e55 Make extractors easier to write (#36)
Previously extractors worked directly on `Request<B>` which meant you
had to do weird tricks like `mem::take(req.headers_mut())` to get owned
parts of the request.

This changes that instead to use a new `RequestParts` type that have
methods to "take" each part of the request. Without having to do weird
tricks.

Also removed the need to have `B: Default` for body extractors.
2021-07-22 13:23:50 +02:00
David Pedersen 5a5710d290 Rename to axum (#28) 2021-07-09 21:36:14 +02:00
David Pedersen 356f1c8424 Generic request body (#22)
Fixes #21
2021-06-19 12:50:33 +02:00
David Pedersen 1002685a20 Rename to awebframework (#13) 2021-06-13 11:22:02 +02:00
David Pedersen 59944c231f Reduce size of response body types (#11)
Wrapping everything in `crate::body::Either` wasn't actually necessary
ans probably causes large body types. You can instead box the bodies in
the leaf services.
2021-06-13 10:10:37 +02:00
David Pedersen 04d62798b6 Reduce body boxing (#9)
Previously, when routing between one or two requests the two body types
would be merged by boxing them. This isn't ideal since it introduces a
layer indirection for each route.

We can't require the services to be routed between as not all services
use the same body type.

This changes that so it instead uses an `Either` enum that implements
`http_body::Body` if each variant does. Will reduce the overall
allocations and hopefully the compiler can optimize things if both
variants are the same.
2021-06-12 23:59:18 +02:00
David Pedersen 21872c9f7a Remove some unnecessary dependencies 2021-06-08 22:27:38 +02:00
David Pedersen 1cf78fa807 More docs 2021-06-08 22:04:28 +02:00
David Pedersen d8b0153939 Write some more docs 2021-06-07 15:45:19 +02:00
David Pedersen 21c96e0aa1 Write a few docs 2021-06-06 23:58:44 +02:00
David Pedersen 46398afc72 Move things around a bit 2021-06-06 11:37:08 +02:00
David Pedersen f690e74275 Support nesting services with error handling 2021-06-01 11:23:56 +02:00
David Pedersen 0e38037c74 More error handling 2021-06-01 00:37:07 +02:00
David Pedersen f6b1a6f435 More work 2021-05-31 16:28:26 +02:00
David Pedersen f4268471b6 Break things into modules 2021-05-30 13:24:03 +02:00
David Pedersen b763eaa037 Fix layer support 2021-05-30 04:28:24 +02:00