Fix for trailing slash in SDK requests
This commit is contained in:
parent
7a2e88bfaa
commit
2fe3285ce7
4 changed files with 15 additions and 5 deletions
|
@ -13,6 +13,8 @@ lazy_static = "1.4.0"
|
||||||
|
|
||||||
axum = "0.7.4"
|
axum = "0.7.4"
|
||||||
axum-server = "0.6.0"
|
axum-server = "0.6.0"
|
||||||
|
tower = "0.4.13"
|
||||||
|
tower-http = { version = "0.5.2", features = ["normalize-path"] }
|
||||||
|
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
|
|
|
@ -31,3 +31,5 @@ ansi_term.workspace = true
|
||||||
prost.workspace = true
|
prost.workspace = true
|
||||||
rbase64.workspace = true
|
rbase64.workspace = true
|
||||||
proto.workspace = true
|
proto.workspace = true
|
||||||
|
tower.workspace = true
|
||||||
|
tower-http.workspace = true
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use axum::extract::Request;
|
||||||
use axum::routing::{get, post};
|
use axum::routing::{get, post};
|
||||||
use axum::Router;
|
use axum::{Router, ServiceExt};
|
||||||
use logging::init_tracing;
|
use logging::init_tracing;
|
||||||
use services::{auth, dispatch, errors};
|
use services::{auth, dispatch, errors};
|
||||||
|
use tokio::net::TcpListener;
|
||||||
|
use tower::Layer;
|
||||||
|
use tower_http::normalize_path::NormalizePathLayer;
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
|
@ -18,7 +22,7 @@ async fn main() -> Result<()> {
|
||||||
let span = tracing::span!(Level::DEBUG, "main");
|
let span = tracing::span!(Level::DEBUG, "main");
|
||||||
let _ = span.enter();
|
let _ = span.enter();
|
||||||
|
|
||||||
let router = Router::new()
|
let app = Router::new()
|
||||||
.route(
|
.route(
|
||||||
dispatch::QUERY_DISPATCH_ENDPOINT,
|
dispatch::QUERY_DISPATCH_ENDPOINT,
|
||||||
get(dispatch::query_dispatch),
|
get(dispatch::query_dispatch),
|
||||||
|
@ -42,11 +46,13 @@ async fn main() -> Result<()> {
|
||||||
)
|
)
|
||||||
.fallback(errors::not_found);
|
.fallback(errors::not_found);
|
||||||
|
|
||||||
|
let app = NormalizePathLayer::trim_trailing_slash().layer(app);
|
||||||
|
|
||||||
let addr = format!("0.0.0.0:{PORT}");
|
let addr = format!("0.0.0.0:{PORT}");
|
||||||
let server = axum_server::bind(addr.parse()?);
|
let server = TcpListener::bind(&addr).await?;
|
||||||
|
|
||||||
tracing::info!("sdkserver is listening at {addr}");
|
tracing::info!("sdkserver is listening at {addr}");
|
||||||
server.serve(router.into_make_service()).await?;
|
axum::serve(server, ServiceExt::<Request>::into_make_service(app)).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use axum::Json;
|
use axum::Json;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
pub const LOGIN_WITH_PASSWORD_ENDPOINT: &str = "/:product_name/mdk/shield/api/login/";
|
pub const LOGIN_WITH_PASSWORD_ENDPOINT: &str = "/:product_name/mdk/shield/api/login";
|
||||||
pub const LOGIN_WITH_SESSION_TOKEN_ENDPOINT: &str = "/:product_name/mdk/shield/api/verify";
|
pub const LOGIN_WITH_SESSION_TOKEN_ENDPOINT: &str = "/:product_name/mdk/shield/api/verify";
|
||||||
pub const GRANTER_LOGIN_VERIFICATION_ENDPOINT: &str = "/:product_name/combo/granter/login/v2/login";
|
pub const GRANTER_LOGIN_VERIFICATION_ENDPOINT: &str = "/:product_name/combo/granter/login/v2/login";
|
||||||
pub const RISKY_API_CHECK_ENDPOINT: &str = "/account/risky/api/check";
|
pub const RISKY_API_CHECK_ENDPOINT: &str = "/account/risky/api/check";
|
||||||
|
|
Loading…
Reference in a new issue