Commit graph

32 commits

Author SHA1 Message Date
Joel Uckelman
2e963cea9d
Add a use of route_service with ServeFile to the static-file-server example (#2361) 2023-11-27 15:49:54 +01:00
David Pedersen
43b14a5f02
Update to latest versions of hyper and http-body (#1882)
Co-authored-by: Michael Scofield <mscofield0@tutanota.com>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2023-11-23 11:03:03 +00:00
David Pedersen
c97967252d Add serve function and remove Server re-export (#1868) 2023-04-21 17:45:31 +02:00
David Pedersen
6703f8634c Remove B type param: Follow ups (#1789)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Michael Scofield <mscofield0@tutanota.com>
2023-04-21 17:45:31 +02:00
David Pedersen
4e4c29175f Remove B type param (#1751)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Michael Scofield <mscofield0@tutanota.com>
2023-04-21 17:45:31 +02:00
Jonas Platte
dc480f7b0e
Re-integrate examples into the root workspace (#1466)
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2023-03-10 12:02:11 +01:00
Moises-Herradon-Cueto
2c1dde7c07
Fix static-file-server example instructions (#1832)
Co-authored-by: MoisesPotato <28111500+MoisesPotato@users.noreply.github.com>
2023-03-10 09:51:22 +01:00
John Downey
db22b7309d
Remove remnants of spa feature (#1802)
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2023-03-03 14:43:19 +00:00
David Pedersen
27f05ad32e
Remove SpaRouter (#1784) 2023-02-25 11:05:23 +01:00
David Pedersen
f726f16b6d
Update to tower-http 0.4 (#1783) 2023-02-24 20:51:30 +00:00
tottoto
6c133be5b7
Refactor initializing tracing-subscriber in examples (#1596)
* Refactor initializing tracing-subscriber

* Revert "Refactor initializing tracing-subscriber"

This reverts commit 0876260bf9 in favor of tracing_subscriber::registry.

* Use EnvFilter::try_from_default_env in chat example

* Use EnvFilter::try_from_default_env in examples
2022-11-30 10:46:19 +01:00
Konstantin Kostiuk
8d6313afa0
Add example of static-file-server using serve dir with handler as service (#1501)
* add example of static-file-seriver using serve dit with handler as service

* update handle return type in example

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

* cargo fmt fix

* change error mapping

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-11-08 20:40:20 +01:00
David Pedersen
199a7a66b8
Expand static file serving example (#1471) 2022-10-11 07:42:48 +00:00
David Pedersen
423308de3c
Add type safe state extractor (#1155)
* begin threading the state through

* Pass state to extractors

* make state extractor work

* make sure nesting with different states work

* impl Service for MethodRouter<()>

* Fix some of axum-macro's tests

* Implement more traits for `State`

* Update examples to use `State`

* consistent naming of request body param

* swap type params

* Default the state param to ()

* fix docs references

* Docs and handler state refactoring

* docs clean ups

* more consistent naming

* when does MethodRouter implement Service?

* add missing docs

* use `Router`'s default state type param

* changelog

* don't use default type param for FromRequest and RequestParts

probably safer for library authors so you don't accidentally forget

* fix examples

* minor docs tweaks

* clarify how to convert handlers into services

* group methods in one impl block

* make sure merged `MethodRouter`s can access state

* fix docs link

* test merge with same state type

* Document how to access state from middleware

* Port cookie extractors to use state to extract keys (#1250)

* Updates ECOSYSTEM with a new sample project (#1252)

* Avoid unhelpful compiler suggestion (#1251)

* fix docs typo

* document how library authors should access state

* Add `RequestParts::with_state`

* fix example

* apply suggestions from review

* add relevant changes to axum-extra and axum-core changelogs

* Add `route_service_with_tsr`

* fix trybuild expectations

* make sure `SpaRouter` works with routers that have state

* Change order of type params on FromRequest and RequestParts

* reverse order of `RequestParts::with_state` args to match type params

* Add `FromRef` trait (#1268)

* Add `FromRef` trait

* Remove unnecessary type params

* format

* fix docs link

* format examples

* Avoid unnecessary `MethodRouter`

* apply suggestions from review

Co-authored-by: Dani Pardo <dani.pardo@inmensys.com>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-08-17 15:13:31 +00:00
David Pedersen
93251fa203
Bump MSRV to 1.56 and update to the 2021 edition (#1098) 2022-06-17 20:11:35 +02:00
David Pedersen
968ee44631
Sort dependencies in Cargo.tomls (#1076)
* sort dependencies

* check sorted deps on CI

* this should fail

* does caching matter?

* fix sorting
2022-06-10 08:59:17 +02:00
David Pedersen
7774cfd1f7
Update static file server example (#1011) 2022-05-08 19:52:34 +00:00
David Pedersen
1fe4558362
Move examples to separate workspace (#978)
* Move examples to separate workspace

* update commands to run examples

* remove debug
2022-04-29 18:53:41 +02:00
David Pedersen
79f6cde3b1
Update to tower-http 0.3.0 (#965)
* Update to tower-http 0.3.0

* changelog link
2022-04-25 14:59:16 +00:00
Jonas Platte
79b94b9bd6
Replace set_var usage in examples (#829)
* examples: Fix inconsistent toml formatting

* examples: Replace set_var usage
2022-03-06 12:37:00 +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
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
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
EdorianDark
513c5a694d
Update tracing-subscriber to 0.3 (#472)
Fixes #469
2021-11-06 14:50:23 +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
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
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
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
Andrei Zolkin
9df57e6ff2
Migrate all examples to use std::env::var_os (#312) 2021-09-12 17:39:43 +02:00
David Pedersen
ca4d9a2bb9
Replace route with Router::new().route() (#215)
This way there is now only one way to create a router:

```rust
use axum::{Router, handler::get};

let app = Router::new()
    .route("/foo", get(handler))
    .route("/foo", get(handler));
```

`nest` was changed in the same way:

```rust
use axum::Router;

let app = Router::new().nest("/foo", service);
```
2021-08-19 22:37:48 +02:00
David Pedersen
97b53768ba
Replace RoutingDsl trait with Router type (#214)
* Remove `RoutingDsl`

* Fix typo
2021-08-19 21:24:32 +02:00
David Pedersen
6c9651c14a
Move all examples to their own crates (#201)
This makes it much clearer which dependencies each example has.
2021-08-18 00:49:01 +02:00