Rename to axum (#28)

This commit is contained in:
David Pedersen 2021-07-09 21:36:14 +02:00 committed by GitHub
parent 3cd4a1d6a6
commit 5a5710d290
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 131 additions and 131 deletions

View File

@ -15,10 +15,10 @@ Please fill in as much of the template below as you're able.
### 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`:
`cargo tree | grep awebframework`
`cargo tree | grep axum`
-->
### Platform
@ -30,7 +30,7 @@ Output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)
### Crates
<!--
If known, please specify the affected awebframework crates. Otherwise, delete this
If known, please specify the affected axum crates. Otherwise, delete this
section.
-->

View File

@ -4,7 +4,7 @@ the requirements below.
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

View File

@ -1,4 +1,4 @@
# Patch dependencies to run all tests against versions of the crate in the
# repository.
[patch.crates-io]
awebframework = { path = "awebframework" }
axum = { path = "axum" }

View File

@ -1,9 +1,9 @@
# Contributing to awebframework
# Contributing to axum
:balloon: Thanks for your help improving the project! We are so happy to have
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
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**.
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
channel][discord], please join us!
@ -21,7 +21,7 @@ channel][discord], please join us!
## 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.
[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:
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
davidpdrsn/awebframework [issue tracker][issues] is the way to report it.
have uncovered a bug in a `axum` crate, creating a new issue in the
davidpdrsn/axum [issue tracker][issues] is the way to report it.
2. By helping to triage the issue: This can be done by 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
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
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
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
@ -59,7 +59,7 @@ PR that helps others avoid the problems that you encountered.
### 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
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
@ -104,7 +104,7 @@ workflow that ensures that the proposed changes meet the minimal quality.
## Pull Requests
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
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:
1. Does this change make sense for awebframework?
2. Does this change make awebframework better, even if only incrementally?
1. Does this change make sense for axum?
2. Does this change make axum better, even if only incrementally?
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
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
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
not want to have anything to do with `awebframework` ever again. The goal is not
particular change that makes `axum` better, but the individual might just
not want to have anything to do with `axum` ever again. The goal is not
just having good code.
### Abandoned or Stalled Pull Requests

View File

@ -4,12 +4,12 @@ categories = [] # TODO
description = "Web framework that focuses on ergonomics and modularity"
documentation = "https://docs.rs/tower-http/0.1.0"
edition = "2018"
homepage = "https://github.com/davidpdrsn/awebframework"
homepage = "https://github.com/davidpdrsn/axum"
keywords = ["http", "web", "framework"]
license = "MIT"
name = "awebframework"
name = "axum"
readme = "README.md"
repository = "https://github.com/davidpdrsn/awebframework"
repository = "https://github.com/davidpdrsn/axum"
version = "0.1.0"
[features]

View File

@ -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.
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.
[![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)
[![Documentation](https://docs.rs/awebframework/badge.svg)](https://docs.rs/awebframework)
[![Crates.io](https://img.shields.io/crates/l/awebframework)](LICENSE)
[![Crates.io](https://img.shields.io/crates/v/axum)](https://crates.io/crates/axum)
[![Documentation](https://docs.rs/axum/badge.svg)](https://docs.rs/axum)
[![Crates.io](https://img.shields.io/crates/l/axum)](LICENSE)
-->
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
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.
- Focus on routing, extracting data from requests, and generating responses.
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.
## Usage example
```rust
use awebframework::prelude::*;
use axum::prelude::*;
use hyper::Server;
use std::net::SocketAddr;
@ -51,12 +51,12 @@ See the [crate documentation][docs] for way more 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
## 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
[`#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
you! We have a [contributing guide][guide] to help you get involved in the
awebframework project.
axum project.
## License
@ -73,13 +73,13 @@ This project is licensed under the [MIT license](LICENSE).
### Contribution
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.
[examples]: https://github.com/davidpdrsn/awebframework/tree/master/examples
[docs]: https://docs.rs/awebframework/0.1.0
[examples]: https://github.com/davidpdrsn/axum/tree/master/examples
[docs]: https://docs.rs/axum/0.1.0
[tower]: https://crates.io/crates/tower
[tower-http]: https://crates.io/crates/tower-http
[guide]: CONTRIBUTING.md
[chat]: https://discord.gg/tokio
[issue]: https://github.com/davidpdrsn/awebframework/issues/new
[issue]: https://github.com/davidpdrsn/axum/issues/new

View File

@ -5,7 +5,7 @@
- [`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.
- [`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.
- [`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.

View File

@ -3,7 +3,7 @@
#![allow(dead_code)]
use awebframework::{
use axum::{
async_trait,
extract::{Extension, Json, UrlParams},
prelude::*,

View File

@ -1,4 +1,4 @@
use awebframework::prelude::*;
use axum::prelude::*;
use serde::Deserialize;
use std::net::SocketAddr;

View File

@ -1,4 +1,4 @@
use awebframework::prelude::*;
use axum::prelude::*;
use std::net::SocketAddr;
#[tokio::main]

View File

@ -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:
//!
@ -6,7 +6,7 @@
//! RUST_LOG=tower_http=debug,key_value_store=trace cargo run --example key_value_store
//! ```
use awebframework::{
use axum::{
extract::{ContentLengthLimit, Extension, UrlParams},
prelude::*,
response::IntoResponse,

View File

@ -1,4 +1,4 @@
use awebframework::{prelude::*, service::ServiceExt};
use axum::{prelude::*, service::ServiceExt};
use http::StatusCode;
use std::net::SocketAddr;
use tower_http::{services::ServeDir, trace::TraceLayer};
@ -7,9 +7,9 @@ use tower_http::{services::ServeDir, trace::TraceLayer};
async fn main() {
tracing_subscriber::fmt::init();
let app = awebframework::routing::nest(
let app = axum::routing::nest(
"/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,
format!("Unhandled interal error: {}", error),

View File

@ -1,5 +1,5 @@
use askama::Template;
use awebframework::{prelude::*, response::IntoResponse};
use axum::{prelude::*, response::IntoResponse};
use http::{Response, StatusCode};
use std::net::SocketAddr;

View File

@ -1,4 +1,4 @@
use awebframework::{prelude::*, routing::BoxRoute};
use axum::{prelude::*, routing::BoxRoute};
use tower_http::trace::TraceLayer;
#[tokio::main]

View File

@ -1,4 +1,4 @@
use awebframework::{extract::Extension, prelude::*, AddExtensionLayer};
use axum::{extract::Extension, prelude::*, AddExtensionLayer};
use bb8::Pool;
use bb8_postgres::PostgresConnectionManager;
use http::StatusCode;

View File

@ -1,5 +1,5 @@
use awebframework::response::IntoResponse;
use awebframework::{async_trait, extract::FromRequest, prelude::*};
use axum::response::IntoResponse;
use axum::{async_trait, extract::FromRequest, prelude::*};
use http::Response;
use http::StatusCode;
use std::net::SocketAddr;

View File

@ -9,7 +9,7 @@
//! --example websocket
//! ```
use awebframework::{
use axum::{
prelude::*,
routing::nest,
service::ServiceExt,
@ -29,7 +29,7 @@ async fn main() {
// build our application with some routes
let app = nest(
"/",
awebframework::service::get(
axum::service::get(
ServeDir::new("examples/websocket")
.append_index_html_on_directories(true)
.handle_error(|error: std::io::Error| {

View File

@ -14,7 +14,7 @@ pub use hyper::body::Body;
/// 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.
pub struct BoxBody {
// when we've gotten rid of `BoxStdError` we should be able to change the error type to

View File

@ -99,7 +99,7 @@ where
}
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);
@ -115,7 +115,7 @@ where
let (reply_tx, reply_rx) = oneshot::channel::<WorkerReply<S::Future, S::Error>>();
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 {
@ -151,7 +151,7 @@ where
let new_state = match this.state.as_mut().project() {
StateProj::Channel(reply_rx) => {
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 {
WorkerReply::Future(future) => State::Future(future),

View File

@ -8,7 +8,7 @@
//! deserializes it as JSON into some target type:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use serde::Deserialize;
//!
//! #[derive(Deserialize)]
@ -34,7 +34,7 @@
//! You can also define your own extractors by implementing [`FromRequest`]:
//!
//! ```rust,no_run
//! use awebframework::{async_trait, extract::FromRequest, prelude::*};
//! use axum::{async_trait, extract::FromRequest, prelude::*};
//! use http::{StatusCode, header::{HeaderValue, USER_AGENT}};
//!
//! struct ExtractUserAgent(HeaderValue);
@ -72,7 +72,7 @@
//! Handlers can also contain multiple extractors:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use std::collections::HashMap;
//!
//! async fn handler(
@ -97,7 +97,7 @@
//! Wrapping extractors in `Option` will make them optional:
//!
//! ```rust,no_run
//! use awebframework::{extract::Json, prelude::*};
//! use axum::{extract::Json, prelude::*};
//! use serde_json::Value;
//!
//! async fn create_user(payload: Option<Json<Value>>) {
@ -118,7 +118,7 @@
//! the extraction failed:
//!
//! ```rust,no_run
//! use awebframework::{extract::{Json, rejection::JsonRejection}, prelude::*};
//! use axum::{extract::{Json, rejection::JsonRejection}, prelude::*};
//! use serde_json::Value;
//!
//! async fn create_user(payload: Result<Json<Value>, JsonRejection>) {
@ -155,7 +155,7 @@
//! directly on the function signature:
//!
//! ```rust,no_run
//! use awebframework::{extract::Json, prelude::*};
//! use axum::{extract::Json, prelude::*};
//! use serde_json::Value;
//!
//! async fn create_user(Json(value): Json<Value>) {
@ -237,7 +237,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use serde::Deserialize;
///
/// #[derive(Deserialize)]
@ -289,7 +289,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use serde::Deserialize;
///
/// #[derive(Deserialize)]
@ -355,7 +355,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use serde::Deserialize;
///
/// #[derive(Deserialize)]
@ -435,7 +435,7 @@ fn has_content_type<B>(req: &Request<B>, expected_content_type: &str) -> bool {
/// # Example
///
/// ```rust,no_run
/// use awebframework::{AddExtensionLayer, prelude::*};
/// use axum::{AddExtensionLayer, prelude::*};
/// use std::sync::Arc;
///
/// // Some shared state used throughout our application
@ -530,7 +530,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use futures::StreamExt;
///
/// async fn handler(mut stream: extract::BodyStream) {
@ -646,7 +646,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::prelude::*;
/// use axum::prelude::*;
///
/// async fn handler(body: extract::ContentLengthLimit<String, 1024>) {
/// // ...
@ -699,7 +699,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::prelude::*;
/// use axum::prelude::*;
///
/// async fn users_show(params: extract::UrlParamsMap) {
/// let id: Option<&str> = params.get("id");
@ -761,7 +761,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::{extract::UrlParams, prelude::*};
/// use axum::{extract::UrlParams, prelude::*};
/// use uuid::Uuid;
///
/// async fn users_teams_show(
@ -862,7 +862,7 @@ where
/// # Example
///
/// ```rust,no_run
/// use awebframework::{extract::TypedHeader, prelude::*};
/// use axum::{extract::TypedHeader, prelude::*};
/// use headers::UserAgent;
///
/// async fn users_teams_show(

View File

@ -119,7 +119,7 @@ define_rejection! {
define_rejection! {
#[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
/// [`UrlParams`](super::UrlParams) if you try and extract the URL params
/// more than once.

View File

@ -2,7 +2,7 @@
//!
//! # 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
//! implements [`IntoResponse`].
//!
@ -11,7 +11,7 @@
//! Some examples of handlers:
//!
//! ```rust
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use bytes::Bytes;
//! use http::StatusCode;
//!
@ -65,7 +65,7 @@ pub mod future;
/// # Example
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
///
/// async fn handler() {}
///
@ -107,7 +107,7 @@ where
/// # Example
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
///
/// async fn handler() {}
///
@ -189,7 +189,7 @@ where
/// # Example
///
/// ```rust
/// use awebframework::{handler::on, routing::MethodFilter, prelude::*};
/// use axum::{handler::on, routing::MethodFilter, prelude::*};
///
/// async fn handler() {}
///
@ -251,7 +251,7 @@ pub trait Handler<B, In>: Sized {
/// can be done like so:
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit};
///
/// async fn handler() { /* ... */ }
@ -403,7 +403,7 @@ impl<S, T> Layered<S, T> {
/// `handle_error` can be used like so:
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use http::StatusCode;
/// use tower::{BoxError, timeout::TimeoutLayer};
/// use std::time::Duration;
@ -562,7 +562,7 @@ impl<S, F> OnMethod<S, F> {
/// # Example
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
///
/// async fn handler() {}
///
@ -648,7 +648,7 @@ impl<S, F> OnMethod<S, F> {
/// # Example
///
/// ```rust
/// use awebframework::{routing::MethodFilter, prelude::*};
/// use axum::{routing::MethodFilter, prelude::*};
///
/// async fn handler() {}
///

View File

@ -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.
//!
//! ## Goals
//!
//! - Ease of use. Building web apps in Rust should be as easy as `async fn
//! 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.
//! - Focus on routing, extracting data from requests, and generating responses.
//! 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.
//!
//! # 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.
//!
//! # Example
//!
//! The "Hello, World!" of awebframework is:
//! The "Hello, World!" of axum is:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use hyper::Server;
//! use std::net::SocketAddr;
//! use tower::make::Shared;
@ -45,7 +45,7 @@
//! Routing between handlers looks like this:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//!
//! let app = route("/", get(get_slash).post(post_slash))
//! .route("/foo", get(get_foo));
@ -75,7 +75,7 @@
//! returned from a handler:
//!
//! ```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 serde_json::{Value, json};
//!
@ -157,7 +157,7 @@
//! body and deserializes it as JSON into some target type:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use serde::Deserialize;
//!
//! let app = route("/users", post(create_user));
@ -183,7 +183,7 @@
//! [`Uuid`]:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use uuid::Uuid;
//!
//! let app = route("/users/:id", post(create_user));
@ -204,7 +204,7 @@
//! You can also apply multiple extractors:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use uuid::Uuid;
//! use serde::Deserialize;
//!
@ -239,7 +239,7 @@
//! Additionally `Request<Body>` is itself an extractor:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//!
//! let app = route("/users/:id", post(handler));
//!
@ -260,7 +260,7 @@
//!
//! # 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:
//!
//! ## Applying middleware to individual handlers
@ -268,7 +268,7 @@
//! A middleware can be applied to a single handler like so:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use tower::limit::ConcurrencyLimitLayer;
//!
//! let app = route(
@ -287,7 +287,7 @@
//! Middleware can also be applied to a group of routes like so:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use tower::limit::ConcurrencyLimitLayer;
//!
//! let app = route("/", get(get_slash))
@ -317,7 +317,7 @@
//! adding a middleware to a handler:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use tower::{
//! BoxError, timeout::{TimeoutLayer, error::Elapsed},
//! };
@ -359,7 +359,7 @@
//! group of routes with middleware applied:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use tower::{BoxError, timeout::TimeoutLayer};
//! use std::time::Duration;
//!
@ -383,7 +383,7 @@
//! [`tower::ServiceBuilder`] can be used to combine multiple middleware:
//!
//! ```rust,no_run
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use tower::{
//! ServiceBuilder, BoxError,
//! load_shed::error::Overloaded,
@ -439,7 +439,7 @@
//! and the [`extract::Extension`] extractor:
//!
//! ```rust,no_run
//! use awebframework::{AddExtensionLayer, prelude::*};
//! use axum::{AddExtensionLayer, prelude::*};
//! use std::sync::Arc;
//!
//! struct State {
@ -464,10 +464,10 @@
//!
//! # Routing to any [`Service`]
//!
//! awebframework also supports routing to general [`Service`]s:
//! axum also supports routing to general [`Service`]s:
//!
//! ```rust,no_run
//! use awebframework::{
//! use axum::{
//! // `ServiceExt` adds `handle_error` to any `Service`
//! service::{self, ServiceExt}, prelude::*,
//! };
@ -504,7 +504,7 @@
//! Applications can be nested by calling [`nest`](routing::nest):
//!
//! ```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 http::Response;
//!
@ -522,7 +522,7 @@
//! [`nest`](routing::nest) can also be used to serve static files from a directory:
//!
//! ```rust,no_run
//! use awebframework::{prelude::*, service::ServiceExt, routing::nest};
//! use axum::{prelude::*, service::ServiceExt, routing::nest};
//! use tower_http::services::ServeDir;
//! use http::Response;
//! use tower::{service_fn, BoxError};
@ -540,7 +540,7 @@
//!
//! # 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.
//!
//! 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 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.
pub use crate::body::Body;
@ -663,7 +663,7 @@ pub mod prelude {
/// # Examples
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// # use std::convert::Infallible;
/// # use http::Response;
/// # let service = tower::service_fn(|_: Request<Body>| async {

View File

@ -204,7 +204,7 @@ impl<T> From<T> for Html<T> {
///
/// ```
/// use serde_json::json;
/// use awebframework::{body::Body, response::{Json, IntoResponse}};
/// use axum::{body::Body, response::{Json, IntoResponse}};
/// use http::{Response, header::CONTENT_TYPE};
///
/// let json = json!({

View File

@ -87,7 +87,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
/// # Example
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
///
/// async fn first_handler() { /* ... */ }
///
@ -134,7 +134,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
/// return them from functions:
///
/// ```rust
/// use awebframework::{routing::BoxRoute, body::Body, prelude::*};
/// use axum::{routing::BoxRoute, body::Body, prelude::*};
///
/// async fn first_handler() { /* ... */ }
///
@ -186,7 +186,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
/// routes can be done like so:
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use tower::limit::{ConcurrencyLimitLayer, ConcurrencyLimit};
///
/// async fn first_handler() { /* ... */ }
@ -212,7 +212,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
/// entire app:
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use tower_http::trace::TraceLayer;
///
/// async fn first_handler() { /* ... */ }
@ -243,7 +243,7 @@ pub trait RoutingDsl: crate::sealed::Sealed + Sized {
/// [`Server`](hyper::server::Server):
///
/// ```
/// use awebframework::prelude::*;
/// use axum::prelude::*;
///
/// let app = route("/", get(|| async { "Hi!" }));
///
@ -624,7 +624,7 @@ impl<S> Layered<S> {
/// That can be done using `handle_error` like so:
///
/// ```rust
/// use awebframework::prelude::*;
/// use axum::prelude::*;
/// use http::StatusCode;
/// use tower::{BoxError, timeout::TimeoutLayer};
/// use std::time::Duration;
@ -700,7 +700,7 @@ where
/// nested route will only see the part of URL:
///
/// ```
/// use awebframework::{routing::nest, prelude::*};
/// use axum::{routing::nest, prelude::*};
/// use http::Uri;
///
/// async fn users_get(uri: Uri) {
@ -725,7 +725,7 @@ where
/// captures from the outer routes:
///
/// ```
/// use awebframework::{routing::nest, prelude::*};
/// use axum::{routing::nest, prelude::*};
///
/// async fn users_get(params: extract::UrlParamsMap) {
/// // 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:
///
/// ```
/// use awebframework::{
/// use axum::{
/// routing::nest, service::{get, ServiceExt}, prelude::*,
/// };
/// use tower_http::services::ServeDir;

View File

@ -11,7 +11,7 @@
//!
//! ```
//! use tower_http::services::Redirect;
//! use awebframework::{service, handler, prelude::*};
//! use axum::{service, handler, prelude::*};
//!
//! async fn handler(request: Request<Body>) { /* ... */ }
//!
@ -41,7 +41,7 @@
//! well when your services don't care about backpressure and are always ready
//! 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
//! 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
@ -51,14 +51,14 @@
//! 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
//! 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
//! around your entire app. This is possible because awebframework applications are
//! around your entire app. This is possible because axum applications are
//! themselves services:
//!
//! ```rust
//! use awebframework::prelude::*;
//! use axum::prelude::*;
//! use tower::ServiceBuilder;
//! # let some_backpressure_sensitive_middleware =
//! # tower::layer::util::Identity::new();
@ -141,7 +141,7 @@ where
/// # Example
///
/// ```rust
/// use awebframework::{service, prelude::*};
/// use axum::{service, prelude::*};
/// use http::Response;
/// use std::convert::Infallible;
/// use hyper::Body;
@ -228,7 +228,7 @@ where
/// # Example
///
/// ```rust
/// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*};
/// use axum::{handler::on, service, routing::MethodFilter, prelude::*};
/// use http::Response;
/// use std::convert::Infallible;
/// use hyper::Body;
@ -306,7 +306,7 @@ impl<S, F> OnMethod<S, F> {
/// # Example
///
/// ```rust
/// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*};
/// use axum::{handler::on, service, routing::MethodFilter, prelude::*};
/// use http::Response;
/// use std::convert::Infallible;
/// use hyper::Body;
@ -399,7 +399,7 @@ impl<S, F> OnMethod<S, F> {
/// # Example
///
/// ```rust
/// use awebframework::{handler::on, service, routing::MethodFilter, prelude::*};
/// use axum::{handler::on, service, routing::MethodFilter, prelude::*};
/// use http::Response;
/// use std::convert::Infallible;
/// use hyper::Body;
@ -544,7 +544,7 @@ pub trait ServiceExt<ReqBody, ResBody>:
/// # Example
///
/// ```rust,no_run
/// use awebframework::{service::{self, ServiceExt}, prelude::*};
/// use axum::{service::{self, ServiceExt}, prelude::*};
/// use http::Response;
/// use tower::{service_fn, BoxError};
///

View File

@ -3,7 +3,7 @@
//! # Example
//!
//! ```
//! use awebframework::{prelude::*, ws::{ws, WebSocket}};
//! use axum::{prelude::*, ws::{ws, WebSocket}};
//!
//! let app = route("/ws", ws(handle_socket));
//!