mirror of
https://github.com/Nutomic/ibis.git
synced 2025-01-10 18:55:48 +00:00
fix tests
This commit is contained in:
parent
d316b782e9
commit
f51cf8b5ac
3 changed files with 11 additions and 7 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1689,6 +1689,7 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower 0.5.1",
|
"tower 0.5.1",
|
||||||
"tower-http",
|
"tower-http",
|
||||||
|
"tower-layer",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
|
|
|
@ -77,6 +77,7 @@ web-sys = "0.3.70"
|
||||||
config = { version = "0.14.0", features = ["toml"] }
|
config = { version = "0.14.0", features = ["toml"] }
|
||||||
doku = "0.21.1"
|
doku = "0.21.1"
|
||||||
smart-default = "0.7.1"
|
smart-default = "0.7.1"
|
||||||
|
tower-layer = "0.3.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.4.1"
|
pretty_assertions = "1.4.1"
|
||||||
|
|
|
@ -29,6 +29,7 @@ use axum::{
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
routing::get,
|
routing::get,
|
||||||
Router,
|
Router,
|
||||||
|
ServiceExt,
|
||||||
};
|
};
|
||||||
use axum_macros::{debug_handler, debug_middleware};
|
use axum_macros::{debug_handler, debug_middleware};
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
|
@ -43,6 +44,7 @@ use log::info;
|
||||||
use reqwest::header::HeaderMap;
|
use reqwest::header::HeaderMap;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tower_http::cors::CorsLayer;
|
use tower_http::cors::CorsLayer;
|
||||||
|
use tower_layer::Layer;
|
||||||
|
|
||||||
pub mod api;
|
pub mod api;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
@ -84,10 +86,6 @@ pub async fn start(config: IbisConfig) -> MyResult<()> {
|
||||||
conf.site_addr = data.config.bind;
|
conf.site_addr = data.config.bind;
|
||||||
let routes = generate_route_list(App);
|
let routes = generate_route_list(App);
|
||||||
|
|
||||||
// Rewrite federation routes
|
|
||||||
// https://docs.rs/axum/0.7.4/axum/middleware/index.html#rewriting-request-uri-in-middleware
|
|
||||||
let middleware = axum::middleware::from_fn(federation_routes_middleware);
|
|
||||||
|
|
||||||
let config = data.clone();
|
let config = data.clone();
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.leptos_routes(&conf, routes, App)
|
.leptos_routes(&conf, routes, App)
|
||||||
|
@ -97,12 +95,16 @@ pub async fn start(config: IbisConfig) -> MyResult<()> {
|
||||||
.nest("/api/v1", api_routes())
|
.nest("/api/v1", api_routes())
|
||||||
.nest("", nodeinfo::config())
|
.nest("", nodeinfo::config())
|
||||||
.layer(FederationMiddleware::new(config))
|
.layer(FederationMiddleware::new(config))
|
||||||
.layer(CorsLayer::permissive())
|
.layer(CorsLayer::permissive());
|
||||||
.layer(middleware);
|
|
||||||
|
// Rewrite federation routes
|
||||||
|
// https://docs.rs/axum/0.7.4/axum/middleware/index.html#rewriting-request-uri-in-middleware
|
||||||
|
let middleware = axum::middleware::from_fn(federation_routes_middleware);
|
||||||
|
let app_with_middleware = middleware.layer(app);
|
||||||
|
|
||||||
info!("Listening on {}", &data.config.bind);
|
info!("Listening on {}", &data.config.bind);
|
||||||
let listener = TcpListener::bind(&data.config.bind).await?;
|
let listener = TcpListener::bind(&data.config.bind).await?;
|
||||||
axum::serve(listener, app.into_make_service()).await?;
|
axum::serve(listener, app_with_middleware.into_make_service()).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue