Remove axum::prelude (#195)

This commit is contained in:
Florian Thelliez
2021-08-18 00:04:15 +02:00
committed by GitHub
parent f083c3e97e
commit d9a06ef14b
43 changed files with 529 additions and 171 deletions
+10 -4
View File
@@ -4,7 +4,13 @@
//! cargo test --example testing
//! ```
use axum::{prelude::*, routing::BoxRoute};
use axum::{
body::Body,
handler::{get, post},
route,
routing::{BoxRoute, RoutingDsl},
Json,
};
use tower_http::trace::TraceLayer;
#[tokio::main]
@@ -32,8 +38,8 @@ fn app() -> BoxRoute<Body> {
route("/", get(|| async { "Hello, World!" }))
.route(
"/json",
post(|payload: extract::Json<serde_json::Value>| async move {
response::Json(serde_json::json!({ "data": payload.0 }))
post(|payload: Json<serde_json::Value>| async move {
Json(serde_json::json!({ "data": payload.0 }))
}),
)
// We can still add middleware
@@ -44,7 +50,7 @@ fn app() -> BoxRoute<Body> {
#[cfg(test)]
mod tests {
use super::*;
use http::StatusCode;
use http::{Request, StatusCode};
use serde_json::{json, Value};
use std::net::{SocketAddr, TcpListener};
use tower::ServiceExt; // for `app.oneshot()`