mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-25 00:00:23 +02:00
Reduce body boxing (#9)
Previously, when routing between one or two requests the two body types would be merged by boxing them. This isn't ideal since it introduces a layer indirection for each route. We can't require the services to be routed between as not all services use the same body type. This changes that so it instead uses an `Either` enum that implements `http_body::Body` if each variant does. Will reduce the overall allocations and hopefully the compiler can optimize things if both variants are the same.
This commit is contained in:
@@ -21,7 +21,6 @@ use tower_http::{
|
||||
compression::CompressionLayer, trace::TraceLayer,
|
||||
};
|
||||
use tower_web::{
|
||||
body::BoxBody,
|
||||
extract::{ContentLengthLimit, Extension, UrlParams},
|
||||
prelude::*,
|
||||
response::IntoResponse,
|
||||
@@ -99,7 +98,7 @@ async fn list_keys(Extension(state): Extension<SharedState>) -> String {
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
fn admin_routes() -> BoxRoute<BoxBody> {
|
||||
fn admin_routes() -> BoxRoute {
|
||||
async fn delete_all_keys(Extension(state): Extension<SharedState>) {
|
||||
state.write().unwrap().db.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user