mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
Rename to axum (#28)
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
+3
-3
@@ -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),
|
||||
|
||||
+15
-15
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
+9
-9
@@ -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() {}
|
||||
///
|
||||
|
||||
+26
-26
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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!({
|
||||
|
||||
+9
-9
@@ -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;
|
||||
|
||||
+10
-10
@@ -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};
|
||||
///
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! use awebframework::{prelude::*, ws::{ws, WebSocket}};
|
||||
//! use axum::{prelude::*, ws::{ws, WebSocket}};
|
||||
//!
|
||||
//! let app = route("/ws", ws(handle_socket));
|
||||
//!
|
||||
|
||||
Reference in New Issue
Block a user