mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-19 00:00:14 +02:00
Replace RoutingDsl trait with Router type (#214)
* Remove `RoutingDsl` * Fix typo
This commit is contained in:
@@ -3,10 +3,7 @@ mod starwars;
|
||||
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
|
||||
use async_graphql::{EmptyMutation, EmptySubscription, Request, Response, Schema};
|
||||
use axum::response::IntoResponse;
|
||||
use axum::{
|
||||
extract::Extension, handler::get, response::Html, route, routing::RoutingDsl,
|
||||
AddExtensionLayer, Json,
|
||||
};
|
||||
use axum::{extract::Extension, handler::get, response::Html, route, AddExtensionLayer, Json};
|
||||
use starwars::{QueryRoot, StarWars, StarWarsSchema};
|
||||
|
||||
async fn graphql_handler(schema: Extension<StarWarsSchema>, req: Json<Request>) -> Json<Response> {
|
||||
|
||||
@@ -11,7 +11,6 @@ use axum::extract::Extension;
|
||||
use axum::handler::get;
|
||||
use axum::response::{Html, IntoResponse};
|
||||
use axum::route;
|
||||
use axum::routing::RoutingDsl;
|
||||
use axum::AddExtensionLayer;
|
||||
use futures::{sink::SinkExt, stream::StreamExt};
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -14,9 +14,7 @@ use axum::{
|
||||
handler::{get, post},
|
||||
http::{Response, StatusCode},
|
||||
response::IntoResponse,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
AddExtensionLayer, Json,
|
||||
route, AddExtensionLayer, Json,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! cargo run -p example-form
|
||||
//! ```
|
||||
|
||||
use axum::{extract::Form, handler::get, response::Html, route, routing::RoutingDsl};
|
||||
use axum::{extract::Form, handler::get, response::Html, route};
|
||||
use serde::Deserialize;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ use axum::{
|
||||
http::{Response, StatusCode},
|
||||
response::Html,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
};
|
||||
use std::net::SocketAddr;
|
||||
use tower::util::MapResponseLayer;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! cargo run -p example-hello-world
|
||||
//! ```
|
||||
|
||||
use axum::{handler::get, route, routing::RoutingDsl};
|
||||
use axum::{handler::get, route};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
#[tokio::main]
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
body::{Body, Bytes},
|
||||
body::Bytes,
|
||||
extract::{ContentLengthLimit, Extension, Path},
|
||||
handler::{delete, get, Handler},
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
route,
|
||||
routing::{BoxRoute, RoutingDsl},
|
||||
routing::{BoxRoute, Router},
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
@@ -108,7 +108,7 @@ async fn list_keys(Extension(state): Extension<SharedState>) -> String {
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
fn admin_routes() -> BoxRoute<Body> {
|
||||
fn admin_routes() -> Router<BoxRoute> {
|
||||
async fn delete_all_keys(Extension(state): Extension<SharedState>) {
|
||||
state.write().unwrap().db.clear();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use axum::{
|
||||
handler::get,
|
||||
response::Html,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
|
||||
@@ -14,9 +14,7 @@ use axum::{
|
||||
handler::get,
|
||||
http::{header::SET_COOKIE, HeaderMap, Response},
|
||||
response::{IntoResponse, Redirect},
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
AddExtensionLayer,
|
||||
route, AddExtensionLayer,
|
||||
};
|
||||
use oauth2::{
|
||||
basic::BasicClient, reqwest::async_http_client, AuthUrl, AuthorizationCode, ClientId,
|
||||
|
||||
@@ -15,9 +15,7 @@ use axum::{
|
||||
StatusCode,
|
||||
},
|
||||
response::IntoResponse,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
AddExtensionLayer,
|
||||
route, AddExtensionLayer,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
@@ -9,7 +9,7 @@ use axum::{
|
||||
handler::get,
|
||||
http::StatusCode,
|
||||
response::sse::{sse, Event, Sse},
|
||||
routing::{nest, RoutingDsl},
|
||||
routing::nest,
|
||||
};
|
||||
use futures::stream::{self, Stream};
|
||||
use std::{convert::Infallible, net::SocketAddr, time::Duration};
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
//! cargo run -p example-static-file-server
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
routing::{nest, RoutingDsl},
|
||||
};
|
||||
use axum::{http::StatusCode, routing::nest};
|
||||
use std::net::SocketAddr;
|
||||
use tower_http::{services::ServeDir, trace::TraceLayer};
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ use axum::{
|
||||
http::{Response, StatusCode},
|
||||
response::{Html, IntoResponse},
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
};
|
||||
use std::{convert::Infallible, net::SocketAddr};
|
||||
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
body::Body,
|
||||
handler::{get, post},
|
||||
route,
|
||||
routing::{BoxRoute, RoutingDsl},
|
||||
routing::{BoxRoute, Router},
|
||||
Json,
|
||||
};
|
||||
use tower_http::trace::TraceLayer;
|
||||
@@ -34,7 +33,7 @@ async fn main() {
|
||||
/// Having a function that produces our app makes it easy to call it from tests
|
||||
/// without having to create an HTTP server.
|
||||
#[allow(dead_code)]
|
||||
fn app() -> BoxRoute<Body> {
|
||||
fn app() -> Router<BoxRoute> {
|
||||
route("/", get(|| async { "Hello, World!" }))
|
||||
.route(
|
||||
"/json",
|
||||
@@ -50,6 +49,7 @@ fn app() -> BoxRoute<Body> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use axum::body::Body;
|
||||
use axum::http::{self, Request, StatusCode};
|
||||
use serde_json::{json, Value};
|
||||
use std::net::{SocketAddr, TcpListener};
|
||||
|
||||
@@ -18,9 +18,7 @@ use axum::{
|
||||
handler::{get, patch},
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
Json,
|
||||
route, Json,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
|
||||
@@ -9,9 +9,7 @@ use axum::{
|
||||
extract::{Extension, FromRequest, RequestParts},
|
||||
handler::get,
|
||||
http::StatusCode,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
AddExtensionLayer,
|
||||
route, AddExtensionLayer,
|
||||
};
|
||||
use bb8::{Pool, PooledConnection};
|
||||
use bb8_postgres::PostgresConnectionManager;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! cargo run -p example-tracing-aka-logging
|
||||
//! ```
|
||||
|
||||
use axum::{handler::get, response::Html, route, routing::RoutingDsl};
|
||||
use axum::{handler::get, response::Html, route};
|
||||
use std::net::SocketAddr;
|
||||
use tower_http::trace::TraceLayer;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ use axum::{
|
||||
handler::get,
|
||||
http::{Method, Request, StatusCode, Uri},
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
};
|
||||
use futures::ready;
|
||||
use hyper::{
|
||||
|
||||
@@ -12,7 +12,6 @@ use axum::{
|
||||
http::{Response, StatusCode},
|
||||
response::IntoResponse,
|
||||
route,
|
||||
routing::RoutingDsl,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
@@ -14,7 +14,7 @@ use axum::{
|
||||
handler::get,
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
routing::{nest, RoutingDsl},
|
||||
routing::nest,
|
||||
};
|
||||
use std::net::SocketAddr;
|
||||
use tower_http::{
|
||||
|
||||
Reference in New Issue
Block a user