mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-24 00:00:16 +02:00
Remove axum::prelude (#195)
This commit is contained in:
+10
-4
@@ -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()`
|
||||
|
||||
Reference in New Issue
Block a user