Split RouterService off of Router (#1381)

This commit is contained in:
Jonas Platte
2022-09-22 12:10:55 +02:00
committed by GitHub
parent 18e3fac5d3
commit 69d64cecc3
26 changed files with 371 additions and 225 deletions
+5 -2
View File
@@ -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()
+1 -1
View File
@@ -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)]
+3 -3
View File
@@ -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