axum/examples
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
..
async-graphql Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
chat Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
customize-extractor-error Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
error-handling-and-dependency-injection Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
form Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
global-404-handler Stores routes in a map (#408) 2021-10-25 20:49:39 +02:00
graceful_shutdown Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
hello-world Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
jwt Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
key-value-store Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
low-level-rustls Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
multipart-form Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
oauth Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
print-request-response Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
reverse-proxy Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
sessions Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
sse Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
static-file-server Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
templates Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
testing Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
tls-rustls Fix compile time regression by boxing routes internally (#404) 2021-10-24 20:52:42 +02:00
todos Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
tokio-postgres Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
tracing-aka-logging Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
unix-domain-socket Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
validator Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
versioning Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
websockets Reorganize method routers for handlers and services (#405) 2021-10-24 20:05:16 +00:00
README.md Add ROAPI to community showcase (#407) 2021-10-25 08:15:16 +02:00

Examples

This folder contains numerous example showing how to use axum. Each example is setup as its own crate so its dependencies are clear.

Community showcase

  • Houseflow: House automation platform written in Rust.
  • Datafuse: Cloud native data warehouse written in Rust.
  • JWT Auth: JWT auth service for educational purposes.
  • ROAPI: Create full-fledged APIs for static datasets without writing a single line of code.