Commit graph

135 commits

Author SHA1 Message Date
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
Kai Jewson
2b6dba49cb
Remove the associated Body type on IntoResponse (#571) 2021-11-28 18:52:18 +01: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
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
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 Pedersen
20fabd87e9
Add CORS example (#512) 2021-11-13 22:18:14 +01:00
Eray Karatay
2507463706
update tls-rustls example (#494) 2021-11-10 15:07:09 +01:00
Imbolc
2ee66e812f
FromStr based empty_string_as_none implementation (#486) 2021-11-09 13:05:31 +01:00
Jonas Platte
9c77ee0295
Use nightly clippy & rustfmt for more style checks (#487) 2021-11-09 11:53:57 +00:00
EdorianDark
513c5a694d
Update tracing-subscriber to 0.3 (#472)
Fixes #469
2021-11-06 14:50:23 +00:00
Eray Karatay
394ba31385
update low-level-rustls example (#465) 2021-11-05 12:02:58 +01:00
David Pedersen
0be0ea6763 Actually run the routing tests 🤦 2021-11-04 12:48:37 +01:00
david-perez
071a1b26e6
Fix typos (#461) 2021-11-03 19:03:46 +00:00
David Pedersen
ba4d8a2357
Move axum crate into workspace subfolder (#458)
* Move axum crate into workspace subfolder

Over time I imagine we're gonna have other crates in this repo that
provide utilities or integrations for axum. This prepares for that by
moving the main axum crate into its own folder.

The README situation is a bit annoying because we want `./README.md`
for viewing the repo on github but `axum/README.md` for crates.io. For
now I've just copy/pasted it and added CI step to make sure they're
identical.

* update changelog link

* Add licenses to all examples

* is this how you install `diff`?

* or maybe this is how?

* fix readme links

* like this?

* fix cargo-deny step

* Try making root readme a symlink

* remove compare readme step

not needed since readme in repo root is now a symlink

* Revert "Add licenses to all examples"

This reverts commit ab321b7fb9.
2021-11-03 12:38:48 +01:00
arctic-alpaca
a442920ba3
Restructure community showcase (#454) 2021-11-03 09:20:01 +01:00
Jordan Gould
1c60255b9f
Add readme example project (#450)
* Add project based on the readme example

* Add readme project link to README.md

* Typo correction

* Update examples/readme-example/Cargo.toml

Use tracing-subscriber 0.2 to match other the other examples

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>

* Update README.md

Use original readme phrasing for crate docs

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>

* Rename readme-exmaple to readme

* Revert tracing call to debug from info

Co-authored-by: Jordan Gould <jordan@tineye.com>
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2021-11-03 07:23:28 +00:00
David Pedersen
98907b8887
Add example showing how to handle empty vs missing query params (#443) 2021-11-02 14:42:47 +01:00
David Pedersen
a048d6443b Revert hello-world example
Was accidentally changed in another PR
2021-11-02 13:07:49 +01:00
David Pedersen
9465128f3e
Rework docs (#437)
This reworks axum's docs in an attempt to make things easier to find. Previously I wasn't a fan of those docs for the same topic were spread across the root module docs and more specific places like types and methods.

This changes it such that the root module docs only gives a high level introduction to a topic, perhaps with a small example, and then link to other places where all the details are. This means `Router` is now the single place to learn about routing, and etc for the topics like handlers and error handling.
2021-11-01 21:13:37 +00:00
Paul Butler
9145c0e396
Add notify.run to community showcase (#435) 2021-10-31 08:22:46 +01:00
David Pedersen
2d1635a6d7
Fix sse and ws examples (#429)
* Fix sse example

* Fix websockets example
2021-10-27 15:52:41 +00:00
David Pedersen
fc9bfb8a50
Add HTTP proxy example (#425) 2021-10-26 20:46:40 +02:00
David Pedersen
e949c47df6
Fix inconsistent naming of WebSocket rejections (#416) 2021-10-25 23:09:47 +00:00
David Pedersen
1634e67e99
Stores routes in a map (#408)
With https://github.com/tokio-rs/axum/pull/404 and https://github.com/tokio-rs/axum/pull/402 all routes now have the same types and thus we don't need to nest them but can instead store them all in a map. This simplifies the routing quite a bit and is faster as well.

High level changes:
- Routes are now stored in a `HashMap<RouteId, Route<B>>`.
- `Router::or` is renamed to `Router::merge` because thats what it does now. It copies all routes from one router to another. This also means overlapping routes will cause a panic which is nice win.
- `Router::merge` now only accepts `Router`s so added `Router::fallback` for adding a global 404 handler.
- The `Or` service has been removed.
- `Router::layer` now only adds layers to the routes you actually have meaning middleware runs _after_ routing. I believe that addresses https://github.com/tokio-rs/axum/issues/380 but will test that on another branch.
2021-10-25 20:49:39 +02:00
QP Hou
fb87a6a4d3
Add ROAPI to community showcase (#407) 2021-10-25 08:15:16 +02:00
David Pedersen
7692baf837
Reorganize method routers for handlers and services (#405)
* Re-organize method routing for handlers

* Re-organize method routing for services

* changelog
2021-10-24 20:05:16 +00:00
David Pedersen
0ee7379d4f
Fix compile time regression by boxing routes internally (#404)
This is a reimplementation of #401 but with the new matchit based router.

Fixes #399
2021-10-24 20:52:42 +02:00
David Pedersen
f10508db0b
Revamp error handling model (#402)
* Revamp error handling model

* changelog improvements and typo fixes

* Fix a few more Infallible bounds

* minor docs fixes
2021-10-24 17:33:03 +00:00
David Pedersen
9fcc884374
Change Connected::connect_info to return Self (#396)
I've been thinking that having an associated type probably isn't
necessary. I imagine most users are either using `SocketAddr` to the
remote connection IP, or writing their own connection struct.
2021-10-19 23:06:15 +02:00
Eray Karatay
a724af3d0a
Add reverse-proxy example (#389) 2021-10-19 22:52:19 +02:00
silvioprog
8ca5538405
Fix typo in main.rs (#381) 2021-10-12 18:20:27 +00:00
David Pedersen
ac291baaec
Fix dead code warnings (#373) 2021-10-07 16:49:57 +02:00
Eray Karatay
b7002f68d5
Update some examples (#364) 2021-10-05 07:50:27 +02:00
David Pedersen
f8154a088c
Add example showing up to customize extractor error (#356)
Lots have been asking about this so makes sense to have an example for.

Once this is merged I'll add a link to it in the docs.
2021-09-30 17:55:58 +00:00
LT
3adc8d733d
Add validator example (#352) 2021-09-28 18:12:23 +02:00
LT
0b3ee5b2ce
Add graceful shutdown example (#349) 2021-09-28 09:08:49 +00:00
Andrei Zolkin
9df57e6ff2
Migrate all examples to use std::env::var_os (#312) 2021-09-12 17:39:43 +02:00
David Pedersen
4e088b40f6
Show how to configure TraceLayer (#314)
This isn't very obvious so makes sense to include in the example
2021-09-10 17:56:00 +00:00
silvioprog
6c13b22cd4
Add JWT example (#306) (#308)
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
2021-09-10 17:51:20 +02:00
Andrei Zolkin
283bbfbd36
Add JWT auth example as community showcase (#309) 2021-09-08 06:15:17 +00:00
zhihanz
835432b5c9
Add datafuse as community showcase (#302) 2021-09-02 08:16:49 +02:00
Ken-Miura
e6ca9e4b04
Fix content-type in example response (#276) 2021-08-26 18:16:41 +00:00
programatik29
1a5f977896
Simplify tls-rustls example (#254)
## Motivation

Current `tls-rustls` example might be inconvenient for some people.

## Solution

Rename current example to `low-level-rustls` and add a high level example in its place.
2021-08-24 09:56:31 +02:00
Eduardo Canellas
1b5359add7
small changes to error handling example (#250) 2021-08-24 07:42:13 +02:00
David Pedersen
6777dc1e5c
Add constructor to Sse (#244)
I think this is more consistent with the rest of the API
2021-08-23 17:51:30 +02:00
David Pedersen
2bbf6105d0
Fix 404 example (#226)
Forgot to actually set the correct status code
2021-08-21 12:02:50 +02:00
David Pedersen
39a0c26795
Add print-request-response example (#216)
* Add `print-request-response` example

Someone asked about this on Discord. I think its worth adding as an
example.

* add missing feature
2021-08-20 09:26:31 +02:00