Commit graph

1415 commits

Author SHA1 Message Date
David Pedersen
94d2b5f8a6 Misc readme/docs improvements 2021-07-30 15:51:59 +02:00
David Pedersen
d843f4378b
Make websocket handlers support extractors (#41) 2021-07-30 15:19:53 +02:00
David Pedersen
d927c819d3 Clarify docs around body extractors 2021-07-23 00:27:08 +02:00
David Pedersen
f25f7f90ff Implement IntoResponse for Body 2021-07-22 21:22:46 +02:00
David Pedersen
1fb80a1129 Implement IntoResponse for HeaderMap 2021-07-22 21:21:53 +02:00
David Pedersen
6d483a623a Add testing example with real HTTP server 2021-07-22 21:12:40 +02:00
David Pedersen
9a419de290 Misc clean up 2021-07-22 21:12:29 +02:00
David Pedersen
ba9c03d146 Update links 2021-07-22 19:39:08 +02:00
David Pedersen
9db3b92df4 Remove disclaimer from readme 2021-07-22 15:50:46 +02:00
David Pedersen
7c37bb818a Update goals in readme 2021-07-22 15:44:59 +02:00
David Pedersen
21db427077 Update examples readme 2021-07-22 15:42:04 +02:00
David Pedersen
e4a0199c76 Add missing TOC link 2021-07-22 15:38:55 +02:00
David Pedersen
6705e79ed7
Add todos example (#38) 2021-07-22 15:38:32 +02:00
David Pedersen
8faed8120f
Docs improvements (#37) 2021-07-22 15:00:33 +02:00
David Pedersen
a658c94f23 Use correct error type if Json serialization fails
Fixes https://github.com/davidpdrsn/axum/issues/35
2021-07-22 13:26:14 +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
e544fe1c39 More flexible generic responses 2021-07-22 11:14:55 +02:00
David Pedersen
028c472c84
Add Multipart extractor for consuming multipart/form-data requests (#32)
Multipart implementation on top of `multer`
2021-07-14 16:53:37 +02:00
David Pedersen
e641caefaf
Remove hyper-h1 and hyper-h2 features (#31) 2021-07-14 16:29:06 +02:00
David Pedersen
341ad61240 Clarify body extractors 2021-07-10 23:46:14 +02:00
David Pedersen
62da1eac00 Allow extractor_middleware to extract the body 2021-07-10 23:39:40 +02:00
David Pedersen
2e2f697f80 Minor docs improvements 2021-07-09 23:39:39 +02:00
David Pedersen
1cbd43cfc4
Add extractor_middleware (#29)
Converts an extractor into a middleware so it can be run for many routes
without having to repeat it in the function signature.
2021-07-09 23:38:59 +02:00
David Pedersen
0c19fa4d52 Minor readme improvements 2021-07-09 21:42:41 +02:00
David Pedersen
f5fa64dae6 Name is no longer pending 2021-07-09 21:37:44 +02:00
David Pedersen
5a5710d290
Rename to axum (#28) 2021-07-09 21:36:14 +02:00
David Pedersen
3cd4a1d6a6
Fix for service as bottom handler (#27)
Would previously fail because of a mismatch in error types.
2021-07-06 09:40:25 +02:00
David Pedersen
c4d266e94d
Allow errors (#26)
This changes error model to actually allow errors. I think if we're going to use this for things like tonic's route we need a more flexible error handling model. The same `handle_error` adaptors are still there but services aren't required to have `Infallible` as their error type. The error type is simply propagated all the way through.
2021-07-05 16:18:39 +02:00
David Pedersen
3fc7f1880f Rename tokio-postgres example 2021-06-19 15:40:46 +02:00
David Pedersen
8d8cc3ba3d
Examples readme (#25)
* Examples readme

* link?
2021-06-19 14:06:49 +02:00
David Pedersen
44577a0108
Add testing example (#24) 2021-06-19 13:44:21 +02:00
David Pedersen
356f1c8424
Generic request body (#22)
Fixes #21
2021-06-19 12:50:33 +02:00
David Pedersen
6a16cd40ca
Add error handling and dependency injection example (#23) 2021-06-19 12:34:42 +02:00
David Pedersen
4fc3d8b5ba
Replace unsafe with unwrap (#20) 2021-06-15 23:18:49 +02:00
David Pedersen
8a82fd00aa
Add bb8 connection pool example (#19)
I figure this will be quite common.
2021-06-15 22:25:41 +02:00
David Pedersen
b6e67eefd7
Add support for extracting typed headers (#18)
Uses the `headers` crate.
2021-06-15 21:27:21 +02:00
David Pedersen
2f6699aeae
Add HTML template example (#17) 2021-06-13 13:58:12 +02:00
David Pedersen
460828a3cb
Add versioning extractor example (#16) 2021-06-13 13:50:56 +02:00
David Pedersen
7684736817 Fix readme link 2021-06-13 13:11:57 +02:00
David Pedersen
97d9cb2ab7 Tweak readme example 2021-06-13 13:09:24 +02:00
David Pedersen
c41c9e0f78
Support extracting URL params multiple times (#15)
Useful when building higher order extractors.
2021-06-13 13:06:33 +02:00
David Pedersen
2b360a7873
Support getting error from extractors (#14)
Makes `Result<T, T::Rejection>` an extractor and makes all extraction errors enums so no type information is lost.
2021-06-13 12:06:59 +02:00
David Pedersen
1002685a20
Rename to awebframework (#13) 2021-06-13 11:22:02 +02:00
David Pedersen
27ebb3db7a
Add Form extractor (#12)
Fixes https://github.com/davidpdrsn/tower-web/issues/2
2021-06-13 11:01:40 +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
7a051eb2d0
Fix static file serving in examples (#10) 2021-06-13 00:17:17 +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
b3bc4e024c
Add RoutingDsl::{serve, into_make_service} (#8) 2021-06-12 21:44:40 +02:00
David Pedersen
c9c507aece
Add support for websockets (#3)
Basically a copy/paste of whats in warp.

Example usage:

```rust
use tower_web::{prelude::*, ws::{ws, WebSocket}};

let app = route("/ws", ws(handle_socket));

async fn handle_socket(mut socket: WebSocket) {
    while let Some(msg) = socket.recv().await {
        let msg = msg.unwrap();
        socket.send(msg).await.unwrap();
    }
}
```
2021-06-12 20:50:30 +02:00
David Pedersen
002e3f92b3
Misc repo setup (#7) 2021-06-12 20:18:21 +02:00