Commit graph

673 commits

Author SHA1 Message Date
Jonas Platte
c8c0bb2ce1
Fix a typo (#605) 2021-12-10 18:34:31 +01:00
David Pedersen
3a259dcec7
axum-debug: Version 0.3.2 (#598)
- Support checking `FromRequest` bounds for extractors whose request body is something else than
  `axum::body::Body`. Use `#[debug_handler(body = YourBodyType)]` to use a different request body
  type ([#595])

[#595]: https://github.com/tokio-rs/axum/pull/595
2021-12-09 10:52:31 +01:00
David Pedersen
8895926f73
Support customizing the request body type in #[debug_handler] (#595) 2021-12-08 19:37:18 +01:00
David Pedersen
4b85b227e1 Update changelog with v0.3.4
This was shipped from the `v0.3.x` branch so wasn't moved to `main`.
2021-12-08 18:38:14 +01:00
David Pedersen
8e439b17f3
Clean up deny.toml (#597) 2021-12-08 18:37:02 +01:00
David Pedersen
9f6be24ecd
axum: Version 0.4.2 (#592)
* axum: Version 0.4.2

This time depending on the correct version of axum-core.

* add missing changelog links
2021-12-06 12:03:13 +00:00
David Pedersen
8e1341d1f6
Release axum, axum-core, and axum-debug (#591) 2021-12-06 10:30:09 +01:00
Kai Jewson
dfb06e721c
Introduce Response type alias as a shorthand for Response<BoxBody> (#590)
* Introduce `Response` type alias as a shorthand

* Don't re-export `Response` at the crate root
2021-12-05 19:16:46 +01:00
David Pedersen
cbb34869d8
Fix debug_handler for Result<impl IntoResponse, Error> and friends (#588)
Fixes #587
2021-12-04 18:24:58 +01:00
David Pedersen
628921bcad
axum-debug 0.3 (#586)
Forgot to ship this one so the latest version would generate wrong code.
2021-12-03 22:42:10 +01:00
David Pedersen
6dcb406ab8 Remove axum-handle-error-extract from ECOSYSTEM.md
Its been integrated into axum 0.4.
2021-12-02 20:47:54 +01:00
David Pedersen
a63843d6c5
Release axum, axum-core, and axum-extra (#582) 2021-12-02 20:02:38 +01:00
David Pedersen
3ec680cce7
Provide more data in Path deserialization error (#574)
* Provide more error in `Path` deserialization error

* Rename

* Add error kind for deserializing sequences

* Rename

* Fix wrong docs

* Rename `MissingRouteParams`

* Rename error to have more consistency

* Rename internal error

* Update changelog

* One last renaming, for now

* Add tests

* Tweak changelog a bit
2021-12-02 08:51:29 +01:00
David Pedersen
66c5142d0c
Update tower-http (#581)
Updates to 0.2 which was just published.
2021-12-01 20:14:25 +00:00
David Pedersen
254d8fde17
Move FromRequest and IntoResponse into new axum-core crate (#564)
* Move `IntoResponse` to axum-core

* Move `FromRequest` to axum-core

* some clean up

* Remove hyper dependency from axum-core

* Fix docs reference

* Use default

* Update changelog

* Remove mention of default type
2021-11-30 13:46:13 +00:00
david-perez
f95c974406
Remove dependency on tower-http's add-extension feature (#580)
It is not currently being used, since `axum/src/add_extension.rs` "is
vendored from `tower-http` to reduce public dependencies".
2021-11-30 14:22:50 +01:00
david-perez
0c3e4a6f3d
Reduce NotFound's visibility (#579)
It is only used in the crate's `routing` module.
2021-11-30 12:37:51 +00:00
david-perez
affab9b4ec
Use Self in RouterFuture's impl block (#578)
For consistency with the other method and the rest of the codebase.
2021-11-30 12:37:05 +00:00
Kai Jewson
2b6dba49cb
Remove the associated Body type on IntoResponse (#571) 2021-11-28 18:52:18 +01:00
Kai Jewson
decdd4c948
Avoid double-boxing bodies where possible (#569)
* Avoid double-boxing bodies where possible

* Extract `try_downcast` to `util` module
2021-11-27 10:20:31 +01:00
David Pedersen
96b353b556
Add Cached extractor (#565)
* extra: Add `Cached` extractor

`Cached` wraps another extractor and caches its result in request
extensions.

* Use newtype to avoid overriding extensions of the same type

* Rename type param
2021-11-25 10:14:31 +00:00
Pure White
5a5800c1ae
feat: default to charset=utf-8 for text content type (#554)
* feat: default to charset=utf-8 for text content type

* added changelog && fix comment

* fix workflow
2021-11-25 08:31:30 +00:00
EdorianDark
c5a33addb7
Add tower-cookies to ecosystem (#562) 2021-11-24 17:44:34 +01:00
John Teske
b5b0c0e491
Update routing layer documentation (#560) 2021-11-24 06:57:29 +00:00
David Pedersen
6d0abd447c
axum-debug: Version 0.2.2 (#553)
- Fix regression causing errors when `#[debug_handler]` was used on functions with multiple
  extractors ([#552])

[#552]: https://github.com/tokio-rs/axum/pull/552
2021-11-22 09:40:35 +00:00
David Pedersen
27e848fbe8
Fix #[debug_handler] for multiple extractors (#552)
* Fix `#[debug_handler]` for multiple extractors

It generated a function for each extractor to check the type but those
functions didn't have unique names.

Fixed by including all idents in the `arg: Extractor` token tree in the
name of the function generated. Not sure there is a simpler way to fix
it.

* just use a counter

* don't need visit feature anymore
2021-11-22 10:28:43 +01:00
Jonas Platte
69fee5864d
Use .to_owned() instead of .to_string() to turn &str into String (#548) 2021-11-19 22:15:47 +00:00
David Pedersen
ab9f1ef993
Change how Resources are added to Routers (#544) 2021-11-19 21:59:07 +01:00
David Pedersen
44a49cb199
axum-debug: Version 0.2.1 (#545)
- Make macro handle more cases such as mutable extractors and handlers taking
  `self` ([#518])

[#518]: https://github.com/tokio-rs/axum/pull/518
2021-11-19 20:38:30 +00:00
David Pedersen
f1f004a057
Make axum-debug handle more cases (#518)
* Make `axum-debug` handle more cases

* Only just trybuild tests on stable

* revert changes to hello-world example

* Remove a bit of duplication

* return error on generics

* address review feedback

* Support associated functions with receiver or returns `Self`

* fix indentation
2021-11-19 21:32:07 +01:00
David Pedersen
22931688f7
Fix Router::merge for overlapping routes same different methods (#543)
Discovered while working on something else that we didn't properly
handle this:

```rust
let one = Router::new().route("/", get(|| async {}));
let two = Router::new().route("/", post(|| async {}));

let app = one.merge(two);
```
2021-11-19 21:15:41 +01:00
David Pedersen
1d94d75c57
Panic instead of silently discarding fallbacks (#529)
This introduces two new possible panics when constructing routers:

- If merging two routers that each have a fallback. Previously that left
  side fallback would be silently discarded.
- If nesting a router that has a fallback. Previously it would be
  silently discarded.

Overall this should make things more explicit and users shouldn't have
to worry "why isn't my fallback" working.

Fixes #488
2021-11-18 22:19:06 +01:00
David Pedersen
badbb14cce
Remove CloneBoxService (#542)
Its been [upstreamed to tower](https://github.com/tower-rs/tower/pull/615).
2021-11-18 22:18:45 +01:00
David Pedersen
f9a437d081
Add Resource to axum-extra (#538) 2021-11-17 22:31:43 +00:00
Jonas Platte
b43b9ed69d
Add axum_extra::response::ErasedJson (#537) 2021-11-17 22:54:02 +01:00
David Pedersen
a16ea65031
Add axum-extra crate (#536)
* Add `axum-extra` crate

Empty for now but now we have a place to put stuff.

I'll make a PR for moving over https://github.com/davidpdrsn/axum-resource.

* remove `authors` field from `Cargo.toml`s
2021-11-17 20:00:32 +00:00
Jonas Platte
2bfd51372e
Use named constants for static header values (#535)
Improves performance by moving some computation to compile time.
2021-11-17 19:53:07 +00:00
David Pedersen
9a410371a6
Move axum-handle-error-extract into axum (#534)
* Move `axum-handle-error-extract` into axum

With 0.4 underway we can now nuke `axum-handle-error-extract` and move
its code directly into axum.

So this replaces the old `HandleErrorLayer` with one that supports async
functions and extractors.

* changelog

* fix CI
2021-11-17 19:09:58 +00:00
David Pedersen
a317072467
Rename box_body to body (#533)
Probably would have been easier to merge this change directly into
`main` first and the backport it to `v0.3.x` but here we are :P

Fixes #528
2021-11-17 12:59:29 +00:00
David Pedersen
939995e80e
Make the B type parameter in Handler default to axum::body::Body (#527)
* Swap type params in `Handler`

* Default `B` type param in `Handler`
2021-11-16 23:00:39 +01:00
David Pedersen
1dc49ae039
Remove unused file (#526)
This should have been removed as part of #521 but guess I missed it.
2021-11-16 20:27:21 +00:00
David Pedersen
c4081ec40e
Update tokio-tungstenite (#525) 2021-11-16 20:22:00 +00:00
David Pedersen
2bd0310463
New method router (#521)
* Empty crate

* basic setup

* Support `HEAD`

* Add remaining methods

* Impl Debug

* Add `MethodRouter::merge`

* WIP

* Support same route with different methods in different calls

* Update changelog

* Bring back `any` and `any_service`

* Address review feedback
2021-11-16 20:49:07 +01:00
david-perez
3cf8ee3b5e
Drop Sync requirement on the handler function (#522)
Since it doesn't need to be called from different threads at the same
time.
2021-11-16 15:00:56 +01:00
Eray Karatay
e2e9f1ff68
add axum-tutorial to ecosystem (#519) 2021-11-15 07:31:41 +00:00
David Pedersen
20fabd87e9
Add CORS example (#512) 2021-11-13 22:18:14 +01:00
David Pedersen
e58336621d
axum-debug: Version 0.2.0 (#511)
- **breaking:** Removed `debug_router` macro.
- **breaking:** Removed `check_service` function.
- **breaking:** Removed `debug_service` function.
2021-11-13 20:44:13 +01:00
David Pedersen
b9dfea6360
Version 0.3.3 (#510)
- Implement `FromRequest` for [`http::request::Parts`] so it can be used an
  extractor ([#489])
- Implement `IntoResponse` for `http::response::Parts` ([#490])

[#489]: https://github.com/tokio-rs/axum/pull/489
[#490]: https://github.com/tokio-rs/axum/pull/490
[`http::request::Parts`]: https://docs.rs/http/latest/http/request/struct.Parts.html
2021-11-13 20:41:47 +01:00
David Pedersen
6372f93cc5
More clearly document accepting multiple methods (#503)
Seen a few users ask about this and could be documented more clearly.
2021-11-13 20:00:04 +01:00
Jonas Platte
89db85d202
axum-debug: Move axum dependency to dev-dependencies (#506) 2021-11-13 17:38:09 +01:00