mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
Split RouterService off of Router (#1381)
This commit is contained in:
@@ -258,7 +258,8 @@ mod tests {
|
||||
let app = Router::<_, Body>::with_state(state)
|
||||
.route("/set", get(set_cookie))
|
||||
.route("/get", get(get_cookie))
|
||||
.route("/remove", get(remove_cookie));
|
||||
.route("/remove", get(remove_cookie))
|
||||
.into_service();
|
||||
|
||||
let res = app
|
||||
.clone()
|
||||
@@ -344,7 +345,9 @@ mod tests {
|
||||
custom_key: CustomKey(Key::generate()),
|
||||
};
|
||||
|
||||
let app = Router::<_, Body>::with_state(state).route("/get", get(get_cookie));
|
||||
let app = Router::<_, Body>::with_state(state)
|
||||
.route("/get", get(get_cookie))
|
||||
.into_service();
|
||||
|
||||
let res = app
|
||||
.clone()
|
||||
|
||||
@@ -95,7 +95,7 @@ pub mod __private {
|
||||
pub(crate) mod test_helpers {
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use axum::{body::HttpBody, BoxError};
|
||||
use axum::{body::HttpBody, BoxError, Router};
|
||||
|
||||
mod test_client {
|
||||
#![allow(dead_code)]
|
||||
|
||||
@@ -159,7 +159,7 @@ impl<B> From<Resource<B>> for Router<B> {
|
||||
mod tests {
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use axum::{extract::Path, http::Method, Router};
|
||||
use axum::{extract::Path, http::Method, routing::RouterService, Router};
|
||||
use http::Request;
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
@@ -174,7 +174,7 @@ mod tests {
|
||||
.update(|Path(id): Path<u64>| async move { format!("users#update id={}", id) })
|
||||
.destroy(|Path(id): Path<u64>| async move { format!("users#destroy id={}", id) });
|
||||
|
||||
let mut app = Router::new().merge(users);
|
||||
let mut app = Router::new().merge(users).into_service();
|
||||
|
||||
assert_eq!(
|
||||
call_route(&mut app, Method::GET, "/users").await,
|
||||
@@ -217,7 +217,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
async fn call_route(app: &mut Router<()>, method: Method, uri: &str) -> String {
|
||||
async fn call_route(app: &mut RouterService, method: Method, uri: &str) -> String {
|
||||
let res = app
|
||||
.ready()
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user