1
use axum::{
2
    Router,
3
    extract::{Request, State},
4
    response::IntoResponse,
5
    routing,
6
};
7

            
8
use super::{super::State as AppState, api_bridge};
9

            
10
506
pub fn new_service(scope_path: &str, state: &AppState) -> Router {
11
506
    Router::new().nest(
12
506
        scope_path,
13
506
        Router::new()
14
506
            .route("/tokeninfo", routing::get(get_tokeninfo))
15
506
            .route("/logout", routing::post(post_logout))
16
506
            .with_state(state.clone()),
17
506
    )
18
506
}
19

            
20
/// `GET /{base}/api/v1/auth/tokeninfo`
21
4
async fn get_tokeninfo(state: State<AppState>, req: Request) -> impl IntoResponse {
22
    const FN_NAME: &'static str = "get_tokeninfo";
23
4
    let api_path = format!("{}/api/v1/auth/tokeninfo", state.auth_base.as_str());
24
4
    let client = state.client.clone();
25
4

            
26
4
    api_bridge(FN_NAME, &client, req, api_path.as_str()).await
27
4
}
28

            
29
/// `POST /{base}/api/v1/auth/logout`
30
4
async fn post_logout(state: State<AppState>, req: Request) -> impl IntoResponse {
31
    const FN_NAME: &'static str = "post_logout";
32
4
    let api_path = format!("{}/api/v1/auth/logout", state.auth_base.as_str());
33
4
    let client = state.client.clone();
34
4

            
35
4
    api_bridge(FN_NAME, &client, req, api_path.as_str()).await
36
4
}