mirror of https://github.com/tokio-rs/axum
Rename to axum (#28)
This commit is contained in:
parent
3cd4a1d6a6
commit
5a5710d290
|
@ -15,10 +15,10 @@ Please fill in as much of the template below as you're able.
|
||||||
### Version
|
### Version
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
List the versions of all `awebframework` crates you are using. The easiest way to get
|
List the versions of all `axum` crates you are using. The easiest way to get
|
||||||
this information is using `cargo tree`:
|
this information is using `cargo tree`:
|
||||||
|
|
||||||
`cargo tree | grep awebframework`
|
`cargo tree | grep axum`
|
||||||
-->
|
-->
|
||||||
|
|
||||||
### Platform
|
### Platform
|
||||||
|
@ -30,7 +30,7 @@ Output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)
|
||||||
### Crates
|
### Crates
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
If known, please specify the affected awebframework crates. Otherwise, delete this
|
If known, please specify the affected axum crates. Otherwise, delete this
|
||||||
section.
|
section.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ the requirements below.
|
||||||
|
|
||||||
Bug fixes and new features should include tests.
|
Bug fixes and new features should include tests.
|
||||||
|
|
||||||
Contributors guide: https://github.com/davidpdrsn/awebframework/blob/master/CONTRIBUTING.md
|
Contributors guide: https://github.com/davidpdrsn/axum/blob/master/CONTRIBUTING.md
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Motivation
|
## Motivation
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Patch dependencies to run all tests against versions of the crate in the
|
# Patch dependencies to run all tests against versions of the crate in the
|
||||||
# repository.
|
# repository.
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
awebframework = { path = "awebframework" }
|
axum = { path = "axum" }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Contributing to awebframework
|
# Contributing to axum
|
||||||
|
|
||||||
:balloon: Thanks for your help improving the project! We are so happy to have
|
:balloon: Thanks for your help improving the project! We are so happy to have
|
||||||
you!
|
you!
|
||||||
|
|
||||||
There are opportunities to contribute to `awebframework` at any level. It doesn't
|
There are opportunities to contribute to `axum` at any level. It doesn't
|
||||||
matter if you are just getting started with Rust or are the most weathered
|
matter if you are just getting started with Rust or are the most weathered
|
||||||
expert, we can use your help.
|
expert, we can use your help.
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ expert, we can use your help.
|
||||||
This guide will help you get started. **Do not let this guide intimidate you**.
|
This guide will help you get started. **Do not let this guide intimidate you**.
|
||||||
It should be considered a map to help you navigate the process.
|
It should be considered a map to help you navigate the process.
|
||||||
|
|
||||||
Don't know where to start? Check [issues labeled with "E-help-wanted"](https://github.com/davidpdrsn/awebframework/issues?q=is%3Aopen+is%3Aissue+label%3AE-help-wanted) or ["E-easy"](https://github.com/davidpdrsn/awebframework/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy).
|
Don't know where to start? Check [issues labeled with "E-help-wanted"](https://github.com/davidpdrsn/axum/issues?q=is%3Aopen+is%3Aissue+label%3AE-help-wanted) or ["E-easy"](https://github.com/davidpdrsn/axum/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy).
|
||||||
|
|
||||||
You may also get help with contributing in the [`tower` Discord
|
You may also get help with contributing in the [`tower` Discord
|
||||||
channel][discord], please join us!
|
channel][discord], please join us!
|
||||||
|
@ -21,7 +21,7 @@ channel][discord], please join us!
|
||||||
|
|
||||||
## Conduct
|
## Conduct
|
||||||
|
|
||||||
The `awebframework` project adheres to the [Rust Code of Conduct][coc]. This
|
The `axum` project adheres to the [Rust Code of Conduct][coc]. This
|
||||||
describes the _minimum_ behavior expected from all contributors.
|
describes the _minimum_ behavior expected from all contributors.
|
||||||
|
|
||||||
[coc]: https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md
|
[coc]: https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md
|
||||||
|
@ -31,8 +31,8 @@ describes the _minimum_ behavior expected from all contributors.
|
||||||
For any issue, there are fundamentally three ways an individual can contribute:
|
For any issue, there are fundamentally three ways an individual can contribute:
|
||||||
|
|
||||||
1. By opening the issue for discussion: For instance, if you believe that you
|
1. By opening the issue for discussion: For instance, if you believe that you
|
||||||
have uncovered a bug in a `awebframework` crate, creating a new issue in the
|
have uncovered a bug in a `axum` crate, creating a new issue in the
|
||||||
davidpdrsn/awebframework [issue tracker][issues] is the way to report it.
|
davidpdrsn/axum [issue tracker][issues] is the way to report it.
|
||||||
|
|
||||||
2. By helping to triage the issue: This can be done by providing
|
2. By helping to triage the issue: This can be done by providing
|
||||||
supporting details (a test case that demonstrates a bug), providing
|
supporting details (a test case that demonstrates a bug), providing
|
||||||
|
@ -42,12 +42,12 @@ For any issue, there are fundamentally three ways an individual can contribute:
|
||||||
3. By helping to resolve the issue: Typically this is done either in the form of
|
3. By helping to resolve the issue: Typically this is done either in the form of
|
||||||
demonstrating that the issue reported is not a problem after all, or more
|
demonstrating that the issue reported is not a problem after all, or more
|
||||||
often, by opening a Pull Request that changes some bit of something in
|
often, by opening a Pull Request that changes some bit of something in
|
||||||
awebframework in a concrete and reviewable manner.
|
axum in a concrete and reviewable manner.
|
||||||
|
|
||||||
**Anybody can participate in any stage of contribution**. We urge you to
|
**Anybody can participate in any stage of contribution**. We urge you to
|
||||||
participate in the discussion around bugs and participate in reviewing PRs.
|
participate in the discussion around bugs and participate in reviewing PRs.
|
||||||
|
|
||||||
[issues]: https://github.com/davidpdrsn/awebframework/issues
|
[issues]: https://github.com/davidpdrsn/axum/issues
|
||||||
|
|
||||||
### Asking for General Help
|
### Asking for General Help
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ PR that helps others avoid the problems that you encountered.
|
||||||
|
|
||||||
### Submitting a Bug Report
|
### Submitting a Bug Report
|
||||||
|
|
||||||
When opening a new issue in the `awebframework` issue tracker, users will
|
When opening a new issue in the `axum` issue tracker, users will
|
||||||
be presented with a [basic template][template] that should be filled in. If you
|
be presented with a [basic template][template] that should be filled in. If you
|
||||||
believe that you have uncovered a bug, please fill out this form, following the
|
believe that you have uncovered a bug, please fill out this form, following the
|
||||||
template to the best of your ability. Do not worry if you cannot answer every
|
template to the best of your ability. Do not worry if you cannot answer every
|
||||||
|
@ -104,7 +104,7 @@ workflow that ensures that the proposed changes meet the minimal quality.
|
||||||
## Pull Requests
|
## Pull Requests
|
||||||
|
|
||||||
Pull Requests are the way concrete changes are made to the code, documentation,
|
Pull Requests are the way concrete changes are made to the code, documentation,
|
||||||
and dependencies in the `awebframework` repository.
|
and dependencies in the `axum` repository.
|
||||||
|
|
||||||
Even tiny pull requests (e.g., one character pull request fixing a typo in API
|
Even tiny pull requests (e.g., one character pull request fixing a typo in API
|
||||||
documentation) are greatly appreciated. Before making a large change, it is
|
documentation) are greatly appreciated. Before making a large change, it is
|
||||||
|
@ -225,8 +225,8 @@ perfect grammar, or exact style matches. Do not succumb to that temptation.
|
||||||
|
|
||||||
Focus first on the most significant aspects of the change:
|
Focus first on the most significant aspects of the change:
|
||||||
|
|
||||||
1. Does this change make sense for awebframework?
|
1. Does this change make sense for axum?
|
||||||
2. Does this change make awebframework better, even if only incrementally?
|
2. Does this change make axum better, even if only incrementally?
|
||||||
3. Are there clear bugs or larger scale issues that need attending to?
|
3. Are there clear bugs or larger scale issues that need attending to?
|
||||||
4. Is the commit message readable and correct? If it contains a breaking change
|
4. Is the commit message readable and correct? If it contains a breaking change
|
||||||
is it clear enough?
|
is it clear enough?
|
||||||
|
@ -257,8 +257,8 @@ with the appropriate reason to keep the conversation flow concise and relevant.
|
||||||
|
|
||||||
Be aware that *how* you communicate requests and reviews in your feedback can
|
Be aware that *how* you communicate requests and reviews in your feedback can
|
||||||
have a significant impact on the success of the Pull Request. Yes, we may land a
|
have a significant impact on the success of the Pull Request. Yes, we may land a
|
||||||
particular change that makes `awebframework` better, but the individual might just
|
particular change that makes `axum` better, but the individual might just
|
||||||
not want to have anything to do with `awebframework` ever again. The goal is not
|
not want to have anything to do with `axum` ever again. The goal is not
|
||||||
just having good code.
|
just having good code.
|
||||||
|
|
||||||
### Abandoned or Stalled Pull Requests
|
### Abandoned or Stalled Pull Requests
|
||||||
|
|
|
@ -4,12 +4,12 @@ categories = [] # TODO
|
||||||
description = "Web framework that focuses on ergonomics and modularity"
|
description = "Web framework that focuses on ergonomics and modularity"
|
||||||
documentation = "https://docs.rs/tower-http/0.1.0"
|
documentation = "https://docs.rs/tower-http/0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
homepage = "https://github.com/davidpdrsn/awebframework"
|
homepage = "https://github.com/davidpdrsn/axum"
|
||||||
keywords = ["http", "web", "framework"]
|
keywords = ["http", "web", "framework"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "awebframework"
|
name = "axum"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/davidpdrsn/awebframework"
|
repository = "https://github.com/davidpdrsn/axum"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
34
README.md
34
README.md
|
@ -1,16 +1,16 @@
|
||||||
# awebframework
|
# axum
|
||||||
|
|
||||||
**WARNING:** awebframework is very much still work in progress. Nothing is released
|
**WARNING:** axum is very much still work in progress. Nothing is released
|
||||||
to crates.io yet and you shouldn't be using this in production.
|
to crates.io yet and you shouldn't be using this in production.
|
||||||
|
|
||||||
awebframework (name pending) is a tiny web application framework that focuses on
|
axum (name pending) is a tiny web application framework that focuses on
|
||||||
ergonomics and modularity.
|
ergonomics and modularity.
|
||||||
|
|
||||||
[![Build status](https://github.com/davidpdrsn/awebframework/workflows/CI/badge.svg)](https://github.com/davidpdrsn/awebframework/actions)
|
[![Build status](https://github.com/davidpdrsn/axum/workflows/CI/badge.svg)](https://github.com/davidpdrsn/axum/actions)
|
||||||
<!--
|
<!--
|
||||||
[![Crates.io](https://img.shields.io/crates/v/awebframework)](https://crates.io/crates/awebframework)
|
[![Crates.io](https://img.shields.io/crates/v/axum)](https://crates.io/crates/axum)
|
||||||
[![Documentation](https://docs.rs/awebframework/badge.svg)](https://docs.rs/awebframework)
|
[![Documentation](https://docs.rs/axum/badge.svg)](https://docs.rs/axum)
|
||||||
[![Crates.io](https://img.shields.io/crates/l/awebframework)](LICENSE)
|
[![Crates.io](https://img.shields.io/crates/l/axum)](LICENSE)
|
||||||
-->
|
-->
|
||||||
|
|
||||||
More information about this crate can be found in the [crate documentation][docs].
|
More information about this crate can be found in the [crate documentation][docs].
|
||||||
|
@ -19,17 +19,17 @@ More information about this crate can be found in the [crate documentation][docs
|
||||||
|
|
||||||
- Ease of use. Building web apps in Rust should be as easy as `async fn
|
- Ease of use. Building web apps in Rust should be as easy as `async fn
|
||||||
handle(Request) -> Response`.
|
handle(Request) -> Response`.
|
||||||
- Solid foundation. awebframework is built on top of tower and makes it easy to
|
- Solid foundation. axum is built on top of tower and makes it easy to
|
||||||
plug in any middleware from the [tower] and [tower-http] ecosystem.
|
plug in any middleware from the [tower] and [tower-http] ecosystem.
|
||||||
- Focus on routing, extracting data from requests, and generating responses.
|
- Focus on routing, extracting data from requests, and generating responses.
|
||||||
Tower middleware can handle the rest.
|
Tower middleware can handle the rest.
|
||||||
- Macro free core. Macro frameworks have their place but awebframework focuses
|
- Macro free core. Macro frameworks have their place but axum focuses
|
||||||
on providing a core that is macro free.
|
on providing a core that is macro free.
|
||||||
|
|
||||||
## Usage example
|
## Usage example
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use awebframework::prelude::*;
|
use axum::prelude::*;
|
||||||
use hyper::Server;
|
use hyper::Server;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ See the [crate documentation][docs] for way more examples.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
The [examples] folder contains various examples of how to use awebframework. The
|
The [examples] folder contains various examples of how to use axum. The
|
||||||
[docs] also have lots of examples
|
[docs] also have lots of examples
|
||||||
|
|
||||||
## Getting Help
|
## Getting Help
|
||||||
|
|
||||||
In the awebframework's repo we also have a [number of examples][examples]
|
In the axum's repo we also have a [number of examples][examples]
|
||||||
showing how to put everything together. You're also welcome to ask in the
|
showing how to put everything together. You're also welcome to ask in the
|
||||||
[`#tower` Discord channel][chat] or open an [issue] with your question.
|
[`#tower` Discord channel][chat] or open an [issue] with your question.
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ showing how to put everything together. You're also welcome to ask in the
|
||||||
|
|
||||||
:balloon: Thanks for your help improving the project! We are so happy to have
|
:balloon: Thanks for your help improving the project! We are so happy to have
|
||||||
you! We have a [contributing guide][guide] to help you get involved in the
|
you! We have a [contributing guide][guide] to help you get involved in the
|
||||||
awebframework project.
|
axum project.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -73,13 +73,13 @@ This project is licensed under the [MIT license](LICENSE).
|
||||||
### Contribution
|
### Contribution
|
||||||
|
|
||||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||||
for inclusion in awebframework by you, shall be licensed as MIT, without any
|
for inclusion in axum by you, shall be licensed as MIT, without any
|
||||||
additional terms or conditions.
|
additional terms or conditions.
|
||||||
|
|
||||||
[examples]: https://github.com/davidpdrsn/awebframework/tree/master/examples
|
[examples]: https://github.com/davidpdrsn/axum/tree/master/examples
|
||||||
[docs]: https://docs.rs/awebframework/0.1.0
|
[docs]: https://docs.rs/axum/0.1.0
|
||||||
[tower]: https://crates.io/crates/tower
|
[tower]: https://crates.io/crates/tower
|
||||||
[tower-http]: https://crates.io/crates/tower-http
|
[tower-http]: https://crates.io/crates/tower-http
|
||||||
[guide]: CONTRIBUTING.md
|
[guide]: CONTRIBUTING.md
|
||||||
[chat]: https://discord.gg/tokio
|
[chat]: https://discord.gg/tokio
|
||||||
[issue]: https://github.com/davidpdrsn/awebframework/issues/new
|
[issue]: https://github.com/davidpdrsn/axum/issues/new
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
- [`form`](../examples/form.rs) - Receiving data from an HTML `<form>`.
|
- [`form`](../examples/form.rs) - Receiving data from an HTML `<form>`.
|
||||||
- [`static_file_server`](../examples/static_file_server.rs) - Serving static files from a directory. Could for example be the baseline for a single page app.
|
- [`static_file_server`](../examples/static_file_server.rs) - Serving static files from a directory. Could for example be the baseline for a single page app.
|
||||||
- [`templates`](../examples/templates.rs) - Rending HTML templates using [askama](https://crates.io/crates/askama).
|
- [`templates`](../examples/templates.rs) - Rending HTML templates using [askama](https://crates.io/crates/askama).
|
||||||
- [`testing`](../examples/testing.rs) - How to test awebframework apps.
|
- [`testing`](../examples/testing.rs) - How to test axum apps.
|
||||||
- [`versioning`](../examples/versioning.rs) - How one might version an API.
|
- [`versioning`](../examples/versioning.rs) - How one might version an API.
|
||||||
- [`websocket`](../examples/websocket.rs) - How to build an app that handles WebSocket connections.
|
- [`websocket`](../examples/websocket.rs) - How to build an app that handles WebSocket connections.
|
||||||
- [`error_handling_and_dependency_injection`](../examples/error_handling_and_dependency_injection.rs) - How to handle errors and dependency injection using trait objects.
|
- [`error_handling_and_dependency_injection`](../examples/error_handling_and_dependency_injection.rs) - How to handle errors and dependency injection using trait objects.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use awebframework::{
|
use axum::{
|
||||||
async_trait,
|
async_trait,
|
||||||
extract::{Extension, Json, UrlParams},
|
extract::{Extension, Json, UrlParams},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use awebframework::prelude::*;
|
use axum::prelude::*;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use awebframework::prelude::*;
|
use axum::prelude::*;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! Simple in-memory key/value store showing features of awebframework.
|
//! Simple in-memory key/value store showing features of axum.
|
||||||
//!
|
//!
|
||||||
//! Run with:
|
//! Run with:
|
||||||
//!
|
//!
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
//! RUST_LOG=tower_http=debug,key_value_store=trace cargo run --example key_value_store
|
//! RUST_LOG=tower_http=debug,key_value_store=trace cargo run --example key_value_store
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use awebframework::{
|
use axum::{
|
||||||
extract::{ContentLengthLimit, Extension, UrlParams},
|
extract::{ContentLengthLimit, Extension, UrlParams},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use awebframework::{prelude::*, service::ServiceExt};
|
use axum::{prelude::*, service::ServiceExt};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use tower_http::{services::ServeDir, trace::TraceLayer};
|
use tower_http::{services::ServeDir, trace::TraceLayer};
|
||||||
|
@ -7,9 +7,9 @@ use tower_http::{services::ServeDir, trace::TraceLayer};
|
||||||
async fn main() {
|
async fn main() {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
let app = awebframework::routing::nest(
|
let app = axum::routing::nest(
|
||||||
"/static",
|
"/static",
|
||||||
awebframework::service::get(ServeDir::new(".").handle_error(|error: std::io::Error| {
|
axum::service::get(ServeDir::new(".").handle_error(|error: std::io::Error| {
|
||||||
(
|
(
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
format!("Unhandled interal error: {}", error),
|
format!("Unhandled interal error: {}", error),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
use awebframework::{prelude::*, response::IntoResponse};
|
use axum::{prelude::*, response::IntoResponse};
|
||||||
use http::{Response, StatusCode};
|
use http::{Response, StatusCode};
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use awebframework::{prelude::*, routing::BoxRoute};
|
use axum::{prelude::*, routing::BoxRoute};
|
||||||
use tower_http::trace::TraceLayer;
|
use tower_http::trace::TraceLayer;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use awebframework::{extract::Extension, prelude::*, AddExtensionLayer};
|
use axum::{extract::Extension, prelude::*, AddExtensionLayer};
|
||||||
use bb8::Pool;
|
use bb8::Pool;
|
||||||
use bb8_postgres::PostgresConnectionManager;
|
use bb8_postgres::PostgresConnectionManager;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use awebframework::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use awebframework::{async_trait, extract::FromRequest, prelude::*};
|
use axum::{async_trait, extract::FromRequest, prelude::*};
|
||||||
use http::Response;
|
use http::Response;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
//! --example websocket
|
//! --example websocket
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use awebframework::{
|
use axum::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
routing::nest,
|
routing::nest,
|
||||||
service::ServiceExt,
|
service::ServiceExt,
|
||||||
|
@ -29,7 +29,7 @@ async fn main() {
|
||||||
// build our application with some routes
|
// build our application with some routes
|
||||||
let app = nest(
|
let app = nest(
|
||||||
"/",
|
"/",
|
||||||
awebframework::service::get(
|
axum::service::get(
|
||||||
ServeDir::new("examples/websocket")
|
ServeDir::new("examples/websocket")
|
||||||
.append_index_html_on_directories(true)
|
.append_index_html_on_directories(true)
|
||||||
.handle_error(|error: std::io::Error| {
|
.handle_error(|error: std::io::Error| {
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub use hyper::body::Body;
|
||||||
|
|
||||||
/// A boxed [`Body`] trait object.
|
/// A boxed [`Body`] trait object.
|
||||||
///
|
///
|
||||||
/// This is used in awebframework as the response body type for applications. Its necessary to unify
|
/// This is used in axum as the response body type for applications. Its necessary to unify
|
||||||
/// multiple response bodies types into one.
|
/// multiple response bodies types into one.
|
||||||
pub struct BoxBody {
|
pub struct BoxBody {
|
||||||
// when we've gotten rid of `BoxStdError` we should be able to change the error type to
|
// when we've gotten rid of `BoxStdError` we should be able to change the error type to
|
||||||
|
|
|
@ -99,7 +99,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let permit = ready!(self.semaphore.poll_acquire(cx))
|
let permit = ready!(self.semaphore.poll_acquire(cx))
|
||||||
.expect("buffer semaphore closed. This is a bug in awebframework and should never happen. Please file an issue");
|
.expect("buffer semaphore closed. This is a bug in axum and should never happen. Please file an issue");
|
||||||
|
|
||||||
self.permit = Some(permit);
|
self.permit = Some(permit);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ where
|
||||||
let (reply_tx, reply_rx) = oneshot::channel::<WorkerReply<S::Future, S::Error>>();
|
let (reply_tx, reply_rx) = oneshot::channel::<WorkerReply<S::Future, S::Error>>();
|
||||||
|
|
||||||
self.tx.send((req, reply_tx)).unwrap_or_else(|_| {
|
self.tx.send((req, reply_tx)).unwrap_or_else(|_| {
|
||||||
panic!("buffer worker not running. This is a bug in awebframework and should never happen. Please file an issue")
|
panic!("buffer worker not running. This is a bug in axum and should never happen. Please file an issue")
|
||||||
});
|
});
|
||||||
|
|
||||||
ResponseFuture {
|
ResponseFuture {
|
||||||
|
@ -151,7 +151,7 @@ where
|
||||||
let new_state = match this.state.as_mut().project() {
|
let new_state = match this.state.as_mut().project() {
|
||||||
StateProj::Channel(reply_rx) => {
|
StateProj::Channel(reply_rx) => {
|
||||||
let msg = ready!(Pin::new(reply_rx).poll(cx))
|
let msg = ready!(Pin::new(reply_rx).poll(cx))
|
||||||
.expect("buffer worker not running. This is a bug in awebframework and should never happen. Please file an issue");
|
.expect("buffer worker not running. This is a bug in axum and should never happen. Please file an issue");
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
WorkerReply::Future(future) => State::Future(future),
|
WorkerReply::Future(future) => State::Future(future),
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//! deserializes it as JSON into some target type:
|
//! deserializes it as JSON into some target type:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use serde::Deserialize;
|
//! use serde::Deserialize;
|
||||||
//!
|
//!
|
||||||
//! #[derive(Deserialize)]
|
//! #[derive(Deserialize)]
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
//! You can also define your own extractors by implementing [`FromRequest`]:
|
//! You can also define your own extractors by implementing [`FromRequest`]:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{async_trait, extract::FromRequest, prelude::*};
|
//! use axum::{async_trait, extract::FromRequest, prelude::*};
|
||||||
//! use http::{StatusCode, header::{HeaderValue, USER_AGENT}};
|
//! use http::{StatusCode, header::{HeaderValue, USER_AGENT}};
|
||||||
//!
|
//!
|
||||||
//! struct ExtractUserAgent(HeaderValue);
|
//! struct ExtractUserAgent(HeaderValue);
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
//! Handlers can also contain multiple extractors:
|
//! Handlers can also contain multiple extractors:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use std::collections::HashMap;
|
//! use std::collections::HashMap;
|
||||||
//!
|
//!
|
||||||
//! async fn handler(
|
//! async fn handler(
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
//! Wrapping extractors in `Option` will make them optional:
|
//! Wrapping extractors in `Option` will make them optional:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{extract::Json, prelude::*};
|
//! use axum::{extract::Json, prelude::*};
|
||||||
//! use serde_json::Value;
|
//! use serde_json::Value;
|
||||||
//!
|
//!
|
||||||
//! async fn create_user(payload: Option<Json<Value>>) {
|
//! async fn create_user(payload: Option<Json<Value>>) {
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
//! the extraction failed:
|
//! the extraction failed:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{extract::{Json, rejection::JsonRejection}, prelude::*};
|
//! use axum::{extract::{Json, rejection::JsonRejection}, prelude::*};
|
||||||
//! use serde_json::Value;
|
//! use serde_json::Value;
|
||||||
//!
|
//!
|
||||||
//! async fn create_user(payload: Result<Json<Value>, JsonRejection>) {
|
//! async fn create_user(payload: Result<Json<Value>, JsonRejection>) {
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
//! directly on the function signature:
|
//! directly on the function signature:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{extract::Json, prelude::*};
|
//! use axum::{extract::Json, prelude::*};
|
||||||
//! use serde_json::Value;
|
//! use serde_json::Value;
|
||||||
//!
|
//!
|
||||||
//! async fn create_user(Json(value): Json<Value>) {
|
//! async fn create_user(Json(value): Json<Value>) {
|
||||||
|
@ -237,7 +237,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use serde::Deserialize;
|
/// use serde::Deserialize;
|
||||||
///
|
///
|
||||||
/// #[derive(Deserialize)]
|
/// #[derive(Deserialize)]
|
||||||
|
@ -289,7 +289,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use serde::Deserialize;
|
/// use serde::Deserialize;
|
||||||
///
|
///
|
||||||
/// #[derive(Deserialize)]
|
/// #[derive(Deserialize)]
|
||||||
|
@ -355,7 +355,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use serde::Deserialize;
|
/// use serde::Deserialize;
|
||||||
///
|
///
|
||||||
/// #[derive(Deserialize)]
|
/// #[derive(Deserialize)]
|
||||||
|
@ -435,7 +435,7 @@ fn has_content_type<B>(req: &Request<B>, expected_content_type: &str) -> bool {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::{AddExtensionLayer, prelude::*};
|
/// use axum::{AddExtensionLayer, prelude::*};
|
||||||
/// use std::sync::Arc;
|
/// use std::sync::Arc;
|
||||||
///
|
///
|
||||||
/// // Some shared state used throughout our application
|
/// // Some shared state used throughout our application
|
||||||
|
@ -530,7 +530,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use futures::StreamExt;
|
/// use futures::StreamExt;
|
||||||
///
|
///
|
||||||
/// async fn handler(mut stream: extract::BodyStream) {
|
/// async fn handler(mut stream: extract::BodyStream) {
|
||||||
|
@ -646,7 +646,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
///
|
///
|
||||||
/// async fn handler(body: extract::ContentLengthLimit<String, 1024>) {
|
/// async fn handler(body: extract::ContentLengthLimit<String, 1024>) {
|
||||||
/// // ...
|
/// // ...
|
||||||
|
@ -699,7 +699,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
///
|
///
|
||||||
/// async fn users_show(params: extract::UrlParamsMap) {
|
/// async fn users_show(params: extract::UrlParamsMap) {
|
||||||
/// let id: Option<&str> = params.get("id");
|
/// let id: Option<&str> = params.get("id");
|
||||||
|
@ -761,7 +761,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::{extract::UrlParams, prelude::*};
|
/// use axum::{extract::UrlParams, prelude::*};
|
||||||
/// use uuid::Uuid;
|
/// use uuid::Uuid;
|
||||||
///
|
///
|
||||||
/// async fn users_teams_show(
|
/// async fn users_teams_show(
|
||||||
|
@ -862,7 +862,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::{extract::TypedHeader, prelude::*};
|
/// use axum::{extract::TypedHeader, prelude::*};
|
||||||
/// use headers::UserAgent;
|
/// use headers::UserAgent;
|
||||||
///
|
///
|
||||||
/// async fn users_teams_show(
|
/// async fn users_teams_show(
|
||||||
|
|
|
@ -119,7 +119,7 @@ define_rejection! {
|
||||||
|
|
||||||
define_rejection! {
|
define_rejection! {
|
||||||
#[status = INTERNAL_SERVER_ERROR]
|
#[status = INTERNAL_SERVER_ERROR]
|
||||||
#[body = "No url params found for matched route. This is a bug in awebframework. Please open an issue"]
|
#[body = "No url params found for matched route. This is a bug in axum. Please open an issue"]
|
||||||
/// Rejection type for [`UrlParamsMap`](super::UrlParamsMap) and
|
/// Rejection type for [`UrlParamsMap`](super::UrlParamsMap) and
|
||||||
/// [`UrlParams`](super::UrlParams) if you try and extract the URL params
|
/// [`UrlParams`](super::UrlParams) if you try and extract the URL params
|
||||||
/// more than once.
|
/// more than once.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! # What is a handler?
|
//! # What is a handler?
|
||||||
//!
|
//!
|
||||||
//! In awebframework a "handler" is an async function that accepts zero or more
|
//! In axum a "handler" is an async function that accepts zero or more
|
||||||
//! ["extractors"](crate::extract) as arguments and returns something that
|
//! ["extractors"](crate::extract) as arguments and returns something that
|
||||||
//! implements [`IntoResponse`].
|
//! implements [`IntoResponse`].
|
||||||
//!
|
//!
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
//! Some examples of handlers:
|
//! Some examples of handlers:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use bytes::Bytes;
|
//! use bytes::Bytes;
|
||||||
//! use http::StatusCode;
|
//! use http::StatusCode;
|
||||||
//!
|
//!
|
||||||
|
@ -65,7 +65,7 @@ pub mod future;
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
///
|
///
|
||||||
/// async fn handler() {}
|
/// async fn handler() {}
|
||||||
///
|
///
|
||||||
|
@ -107,7 +107,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
///
|
///
|
||||||
/// async fn handler() {}
|
/// async fn handler() {}
|
||||||
///
|
///
|
||||||
|
@ -189,7 +189,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::{handler::on, routing::MethodFilter, prelude::*};
|
/// use axum::{handler::on, routing::MethodFilter, prelude::*};
|
||||||
///
|
///
|
||||||
/// async fn handler() {}
|
/// async fn handler() {}
|
||||||
///
|
///
|
||||||
|
@ -251,7 +251,7 @@ pub trait Handler<B, In>: Sized {
|
||||||
/// can be done like so:
|
/// can be done like so:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit};
|
/// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit};
|
||||||
///
|
///
|
||||||
/// async fn handler() { /* ... */ }
|
/// async fn handler() { /* ... */ }
|
||||||
|
@ -403,7 +403,7 @@ impl<S, T> Layered<S, T> {
|
||||||
/// `handle_error` can be used like so:
|
/// `handle_error` can be used like so:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use http::StatusCode;
|
/// use http::StatusCode;
|
||||||
/// use tower::{BoxError, timeout::TimeoutLayer};
|
/// use tower::{BoxError, timeout::TimeoutLayer};
|
||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
|
@ -562,7 +562,7 @@ impl<S, F> OnMethod<S, F> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
///
|
///
|
||||||
/// async fn handler() {}
|
/// async fn handler() {}
|
||||||
///
|
///
|
||||||
|
@ -648,7 +648,7 @@ impl<S, F> OnMethod<S, F> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::{routing::MethodFilter, prelude::*};
|
/// use axum::{routing::MethodFilter, prelude::*};
|
||||||
///
|
///
|
||||||
/// async fn handler() {}
|
/// async fn handler() {}
|
||||||
///
|
///
|
||||||
|
|
52
src/lib.rs
52
src/lib.rs
|
@ -1,28 +1,28 @@
|
||||||
//! awebframework (name pending) is a tiny web application framework that focuses on
|
//! axum (name pending) is a tiny web application framework that focuses on
|
||||||
//! ergonomics and modularity.
|
//! ergonomics and modularity.
|
||||||
//!
|
//!
|
||||||
//! ## Goals
|
//! ## Goals
|
||||||
//!
|
//!
|
||||||
//! - Ease of use. Building web apps in Rust should be as easy as `async fn
|
//! - Ease of use. Building web apps in Rust should be as easy as `async fn
|
||||||
//! handle(Request) -> Response`.
|
//! handle(Request) -> Response`.
|
||||||
//! - Solid foundation. awebframework is built on top of tower and makes it easy to
|
//! - Solid foundation. axum is built on top of tower and makes it easy to
|
||||||
//! plug in any middleware from the [tower] and [tower-http] ecosystem.
|
//! plug in any middleware from the [tower] and [tower-http] ecosystem.
|
||||||
//! - Focus on routing, extracting data from requests, and generating responses.
|
//! - Focus on routing, extracting data from requests, and generating responses.
|
||||||
//! Tower middleware can handle the rest.
|
//! Tower middleware can handle the rest.
|
||||||
//! - Macro free core. Macro frameworks have their place but awebframework focuses
|
//! - Macro free core. Macro frameworks have their place but axum focuses
|
||||||
//! on providing a core that is macro free.
|
//! on providing a core that is macro free.
|
||||||
//!
|
//!
|
||||||
//! # Compatibility
|
//! # Compatibility
|
||||||
//!
|
//!
|
||||||
//! awebframework is designed to work with [tokio] and [hyper]. Runtime and
|
//! axum is designed to work with [tokio] and [hyper]. Runtime and
|
||||||
//! transport layer independence is not a goal, at least for the time being.
|
//! transport layer independence is not a goal, at least for the time being.
|
||||||
//!
|
//!
|
||||||
//! # Example
|
//! # Example
|
||||||
//!
|
//!
|
||||||
//! The "Hello, World!" of awebframework is:
|
//! The "Hello, World!" of axum is:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use hyper::Server;
|
//! use hyper::Server;
|
||||||
//! use std::net::SocketAddr;
|
//! use std::net::SocketAddr;
|
||||||
//! use tower::make::Shared;
|
//! use tower::make::Shared;
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
//! Routing between handlers looks like this:
|
//! Routing between handlers looks like this:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! let app = route("/", get(get_slash).post(post_slash))
|
//! let app = route("/", get(get_slash).post(post_slash))
|
||||||
//! .route("/foo", get(get_foo));
|
//! .route("/foo", get(get_foo));
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
//! returned from a handler:
|
//! returned from a handler:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{body::Body, response::{Html, Json}, prelude::*};
|
//! use axum::{body::Body, response::{Html, Json}, prelude::*};
|
||||||
//! use http::{StatusCode, Response, Uri};
|
//! use http::{StatusCode, Response, Uri};
|
||||||
//! use serde_json::{Value, json};
|
//! use serde_json::{Value, json};
|
||||||
//!
|
//!
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
//! body and deserializes it as JSON into some target type:
|
//! body and deserializes it as JSON into some target type:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use serde::Deserialize;
|
//! use serde::Deserialize;
|
||||||
//!
|
//!
|
||||||
//! let app = route("/users", post(create_user));
|
//! let app = route("/users", post(create_user));
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
//! [`Uuid`]:
|
//! [`Uuid`]:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use uuid::Uuid;
|
//! use uuid::Uuid;
|
||||||
//!
|
//!
|
||||||
//! let app = route("/users/:id", post(create_user));
|
//! let app = route("/users/:id", post(create_user));
|
||||||
|
@ -204,7 +204,7 @@
|
||||||
//! You can also apply multiple extractors:
|
//! You can also apply multiple extractors:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use uuid::Uuid;
|
//! use uuid::Uuid;
|
||||||
//! use serde::Deserialize;
|
//! use serde::Deserialize;
|
||||||
//!
|
//!
|
||||||
|
@ -239,7 +239,7 @@
|
||||||
//! Additionally `Request<Body>` is itself an extractor:
|
//! Additionally `Request<Body>` is itself an extractor:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! let app = route("/users/:id", post(handler));
|
//! let app = route("/users/:id", post(handler));
|
||||||
//!
|
//!
|
||||||
|
@ -260,7 +260,7 @@
|
||||||
//!
|
//!
|
||||||
//! # Applying middleware
|
//! # Applying middleware
|
||||||
//!
|
//!
|
||||||
//! awebframework is designed to take full advantage of the tower and tower-http
|
//! axum is designed to take full advantage of the tower and tower-http
|
||||||
//! ecosystem of middleware:
|
//! ecosystem of middleware:
|
||||||
//!
|
//!
|
||||||
//! ## Applying middleware to individual handlers
|
//! ## Applying middleware to individual handlers
|
||||||
|
@ -268,7 +268,7 @@
|
||||||
//! A middleware can be applied to a single handler like so:
|
//! A middleware can be applied to a single handler like so:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use tower::limit::ConcurrencyLimitLayer;
|
//! use tower::limit::ConcurrencyLimitLayer;
|
||||||
//!
|
//!
|
||||||
//! let app = route(
|
//! let app = route(
|
||||||
|
@ -287,7 +287,7 @@
|
||||||
//! Middleware can also be applied to a group of routes like so:
|
//! Middleware can also be applied to a group of routes like so:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use tower::limit::ConcurrencyLimitLayer;
|
//! use tower::limit::ConcurrencyLimitLayer;
|
||||||
//!
|
//!
|
||||||
//! let app = route("/", get(get_slash))
|
//! let app = route("/", get(get_slash))
|
||||||
|
@ -317,7 +317,7 @@
|
||||||
//! adding a middleware to a handler:
|
//! adding a middleware to a handler:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use tower::{
|
//! use tower::{
|
||||||
//! BoxError, timeout::{TimeoutLayer, error::Elapsed},
|
//! BoxError, timeout::{TimeoutLayer, error::Elapsed},
|
||||||
//! };
|
//! };
|
||||||
|
@ -359,7 +359,7 @@
|
||||||
//! group of routes with middleware applied:
|
//! group of routes with middleware applied:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use tower::{BoxError, timeout::TimeoutLayer};
|
//! use tower::{BoxError, timeout::TimeoutLayer};
|
||||||
//! use std::time::Duration;
|
//! use std::time::Duration;
|
||||||
//!
|
//!
|
||||||
|
@ -383,7 +383,7 @@
|
||||||
//! [`tower::ServiceBuilder`] can be used to combine multiple middleware:
|
//! [`tower::ServiceBuilder`] can be used to combine multiple middleware:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use tower::{
|
//! use tower::{
|
||||||
//! ServiceBuilder, BoxError,
|
//! ServiceBuilder, BoxError,
|
||||||
//! load_shed::error::Overloaded,
|
//! load_shed::error::Overloaded,
|
||||||
|
@ -439,7 +439,7 @@
|
||||||
//! and the [`extract::Extension`] extractor:
|
//! and the [`extract::Extension`] extractor:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{AddExtensionLayer, prelude::*};
|
//! use axum::{AddExtensionLayer, prelude::*};
|
||||||
//! use std::sync::Arc;
|
//! use std::sync::Arc;
|
||||||
//!
|
//!
|
||||||
//! struct State {
|
//! struct State {
|
||||||
|
@ -464,10 +464,10 @@
|
||||||
//!
|
//!
|
||||||
//! # Routing to any [`Service`]
|
//! # Routing to any [`Service`]
|
||||||
//!
|
//!
|
||||||
//! awebframework also supports routing to general [`Service`]s:
|
//! axum also supports routing to general [`Service`]s:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{
|
//! use axum::{
|
||||||
//! // `ServiceExt` adds `handle_error` to any `Service`
|
//! // `ServiceExt` adds `handle_error` to any `Service`
|
||||||
//! service::{self, ServiceExt}, prelude::*,
|
//! service::{self, ServiceExt}, prelude::*,
|
||||||
//! };
|
//! };
|
||||||
|
@ -504,7 +504,7 @@
|
||||||
//! Applications can be nested by calling [`nest`](routing::nest):
|
//! Applications can be nested by calling [`nest`](routing::nest):
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{prelude::*, routing::BoxRoute, body::{Body, BoxBody}};
|
//! use axum::{prelude::*, routing::BoxRoute, body::{Body, BoxBody}};
|
||||||
//! use tower_http::services::ServeFile;
|
//! use tower_http::services::ServeFile;
|
||||||
//! use http::Response;
|
//! use http::Response;
|
||||||
//!
|
//!
|
||||||
|
@ -522,7 +522,7 @@
|
||||||
//! [`nest`](routing::nest) can also be used to serve static files from a directory:
|
//! [`nest`](routing::nest) can also be used to serve static files from a directory:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use awebframework::{prelude::*, service::ServiceExt, routing::nest};
|
//! use axum::{prelude::*, service::ServiceExt, routing::nest};
|
||||||
//! use tower_http::services::ServeDir;
|
//! use tower_http::services::ServeDir;
|
||||||
//! use http::Response;
|
//! use http::Response;
|
||||||
//! use tower::{service_fn, BoxError};
|
//! use tower::{service_fn, BoxError};
|
||||||
|
@ -540,7 +540,7 @@
|
||||||
//!
|
//!
|
||||||
//! # Features
|
//! # Features
|
||||||
//!
|
//!
|
||||||
//! awebframework uses a set of [feature flags] to reduce the amount of compiled and
|
//! axum uses a set of [feature flags] to reduce the amount of compiled and
|
||||||
//! optional dependencies.
|
//! optional dependencies.
|
||||||
//!
|
//!
|
||||||
//! The following optional features are available:
|
//! The following optional features are available:
|
||||||
|
@ -634,7 +634,7 @@ pub use async_trait::async_trait;
|
||||||
pub use tower_http::add_extension::{AddExtension, AddExtensionLayer};
|
pub use tower_http::add_extension::{AddExtension, AddExtensionLayer};
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
//! Re-exports of important traits, types, and functions used with awebframework. Meant to be glob
|
//! Re-exports of important traits, types, and functions used with axum. Meant to be glob
|
||||||
//! imported.
|
//! imported.
|
||||||
|
|
||||||
pub use crate::body::Body;
|
pub use crate::body::Body;
|
||||||
|
@ -663,7 +663,7 @@ pub mod prelude {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// # use std::convert::Infallible;
|
/// # use std::convert::Infallible;
|
||||||
/// # use http::Response;
|
/// # use http::Response;
|
||||||
/// # let service = tower::service_fn(|_: Request<Body>| async {
|
/// # let service = tower::service_fn(|_: Request<Body>| async {
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl<T> From<T> for Html<T> {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use serde_json::json;
|
/// use serde_json::json;
|
||||||
/// use awebframework::{body::Body, response::{Json, IntoResponse}};
|
/// use axum::{body::Body, response::{Json, IntoResponse}};
|
||||||
/// use http::{Response, header::CONTENT_TYPE};
|
/// use http::{Response, header::CONTENT_TYPE};
|
||||||
///
|
///
|
||||||
/// let json = json!({
|
/// let json = json!({
|
||||||
|
|
|
@ -87,7 +87,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
///
|
///
|
||||||
/// async fn first_handler() { /* ... */ }
|
/// async fn first_handler() { /* ... */ }
|
||||||
///
|
///
|
||||||
|
@ -134,7 +134,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
|
||||||
/// return them from functions:
|
/// return them from functions:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::{routing::BoxRoute, body::Body, prelude::*};
|
/// use axum::{routing::BoxRoute, body::Body, prelude::*};
|
||||||
///
|
///
|
||||||
/// async fn first_handler() { /* ... */ }
|
/// async fn first_handler() { /* ... */ }
|
||||||
///
|
///
|
||||||
|
@ -186,7 +186,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
|
||||||
/// routes can be done like so:
|
/// routes can be done like so:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit};
|
/// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit};
|
||||||
///
|
///
|
||||||
/// async fn first_handler() { /* ... */ }
|
/// async fn first_handler() { /* ... */ }
|
||||||
|
@ -212,7 +212,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
|
||||||
/// entire app:
|
/// entire app:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use tower_http::trace::TraceLayer;
|
/// use tower_http::trace::TraceLayer;
|
||||||
///
|
///
|
||||||
/// async fn first_handler() { /* ... */ }
|
/// async fn first_handler() { /* ... */ }
|
||||||
|
@ -243,7 +243,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
|
||||||
/// [`Server`](hyper::server::Server):
|
/// [`Server`](hyper::server::Server):
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
///
|
///
|
||||||
/// let app = route("/", get(|| async { "Hi!" }));
|
/// let app = route("/", get(|| async { "Hi!" }));
|
||||||
///
|
///
|
||||||
|
@ -624,7 +624,7 @@ impl<S> Layered<S> {
|
||||||
/// That can be done using `handle_error` like so:
|
/// That can be done using `handle_error` like so:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::prelude::*;
|
/// use axum::prelude::*;
|
||||||
/// use http::StatusCode;
|
/// use http::StatusCode;
|
||||||
/// use tower::{BoxError, timeout::TimeoutLayer};
|
/// use tower::{BoxError, timeout::TimeoutLayer};
|
||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
|
@ -700,7 +700,7 @@ where
|
||||||
/// nested route will only see the part of URL:
|
/// nested route will only see the part of URL:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use awebframework::{routing::nest, prelude::*};
|
/// use axum::{routing::nest, prelude::*};
|
||||||
/// use http::Uri;
|
/// use http::Uri;
|
||||||
///
|
///
|
||||||
/// async fn users_get(uri: Uri) {
|
/// async fn users_get(uri: Uri) {
|
||||||
|
@ -725,7 +725,7 @@ where
|
||||||
/// captures from the outer routes:
|
/// captures from the outer routes:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use awebframework::{routing::nest, prelude::*};
|
/// use axum::{routing::nest, prelude::*};
|
||||||
///
|
///
|
||||||
/// async fn users_get(params: extract::UrlParamsMap) {
|
/// async fn users_get(params: extract::UrlParamsMap) {
|
||||||
/// // Both `version` and `id` were captured even though `users_api` only
|
/// // Both `version` and `id` were captured even though `users_api` only
|
||||||
|
@ -746,7 +746,7 @@ where
|
||||||
/// [`tower_http::services::ServeDir`] to serve static files from a directory:
|
/// [`tower_http::services::ServeDir`] to serve static files from a directory:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use awebframework::{
|
/// use axum::{
|
||||||
/// routing::nest, service::{get, ServiceExt}, prelude::*,
|
/// routing::nest, service::{get, ServiceExt}, prelude::*,
|
||||||
/// };
|
/// };
|
||||||
/// use tower_http::services::ServeDir;
|
/// use tower_http::services::ServeDir;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use tower_http::services::Redirect;
|
//! use tower_http::services::Redirect;
|
||||||
//! use awebframework::{service, handler, prelude::*};
|
//! use axum::{service, handler, prelude::*};
|
||||||
//!
|
//!
|
||||||
//! async fn handler(request: Request<Body>) { /* ... */ }
|
//! async fn handler(request: Request<Body>) { /* ... */ }
|
||||||
//!
|
//!
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
//! well when your services don't care about backpressure and are always ready
|
//! well when your services don't care about backpressure and are always ready
|
||||||
//! anyway.
|
//! anyway.
|
||||||
//!
|
//!
|
||||||
//! awebframework expects that all services used in your app wont care about
|
//! axum expects that all services used in your app wont care about
|
||||||
//! backpressure and so it uses the latter strategy. However that means you
|
//! backpressure and so it uses the latter strategy. However that means you
|
||||||
//! should avoid routing to a service (or using a middleware) that _does_ care
|
//! should avoid routing to a service (or using a middleware) that _does_ care
|
||||||
//! about backpressure. At the very least you should [load shed] so requests are
|
//! about backpressure. At the very least you should [load shed] so requests are
|
||||||
|
@ -51,14 +51,14 @@
|
||||||
//! in the response future from `call`, and _not_ from `poll_ready`. In that
|
//! in the response future from `call`, and _not_ from `poll_ready`. In that
|
||||||
//! case the underlying service will _not_ be discarded and will continue to be
|
//! case the underlying service will _not_ be discarded and will continue to be
|
||||||
//! used for future requests. Services that expect to be discarded if
|
//! used for future requests. Services that expect to be discarded if
|
||||||
//! `poll_ready` fails should _not_ be used with awebframework.
|
//! `poll_ready` fails should _not_ be used with axum.
|
||||||
//!
|
//!
|
||||||
//! One possible approach is to only apply backpressure sensitive middleware
|
//! One possible approach is to only apply backpressure sensitive middleware
|
||||||
//! around your entire app. This is possible because awebframework applications are
|
//! around your entire app. This is possible because axum applications are
|
||||||
//! themselves services:
|
//! themselves services:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use awebframework::prelude::*;
|
//! use axum::prelude::*;
|
||||||
//! use tower::ServiceBuilder;
|
//! use tower::ServiceBuilder;
|
||||||
//! # let some_backpressure_sensitive_middleware =
|
//! # let some_backpressure_sensitive_middleware =
|
||||||
//! # tower::layer::util::Identity::new();
|
//! # tower::layer::util::Identity::new();
|
||||||
|
@ -141,7 +141,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::{service, prelude::*};
|
/// use axum::{service, prelude::*};
|
||||||
/// use http::Response;
|
/// use http::Response;
|
||||||
/// use std::convert::Infallible;
|
/// use std::convert::Infallible;
|
||||||
/// use hyper::Body;
|
/// use hyper::Body;
|
||||||
|
@ -228,7 +228,7 @@ where
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*};
|
/// use axum::{handler::on, service, routing::MethodFilter, prelude::*};
|
||||||
/// use http::Response;
|
/// use http::Response;
|
||||||
/// use std::convert::Infallible;
|
/// use std::convert::Infallible;
|
||||||
/// use hyper::Body;
|
/// use hyper::Body;
|
||||||
|
@ -306,7 +306,7 @@ impl<S, F> OnMethod<S, F> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*};
|
/// use axum::{handler::on, service, routing::MethodFilter, prelude::*};
|
||||||
/// use http::Response;
|
/// use http::Response;
|
||||||
/// use std::convert::Infallible;
|
/// use std::convert::Infallible;
|
||||||
/// use hyper::Body;
|
/// use hyper::Body;
|
||||||
|
@ -399,7 +399,7 @@ impl<S, F> OnMethod<S, F> {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*};
|
/// use axum::{handler::on, service, routing::MethodFilter, prelude::*};
|
||||||
/// use http::Response;
|
/// use http::Response;
|
||||||
/// use std::convert::Infallible;
|
/// use std::convert::Infallible;
|
||||||
/// use hyper::Body;
|
/// use hyper::Body;
|
||||||
|
@ -544,7 +544,7 @@ pub trait ServiceExt<ReqBody, ResBody>:
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// use awebframework::{service::{self, ServiceExt}, prelude::*};
|
/// use axum::{service::{self, ServiceExt}, prelude::*};
|
||||||
/// use http::Response;
|
/// use http::Response;
|
||||||
/// use tower::{service_fn, BoxError};
|
/// use tower::{service_fn, BoxError};
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//! # Example
|
//! # Example
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use awebframework::{prelude::*, ws::{ws, WebSocket}};
|
//! use axum::{prelude::*, ws::{ws, WebSocket}};
|
||||||
//!
|
//!
|
||||||
//! let app = route("/ws", ws(handle_socket));
|
//! let app = route("/ws", ws(handle_socket));
|
||||||
//!
|
//!
|
||||||
|
|
Loading…
Reference in New Issue