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

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

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

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

            
25
2
    api_bridge(FN_NAME, &client, req, api_path.as_str()).await
26
2
}
27

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

            
34
2
    api_bridge(FN_NAME, &client, req, api_path.as_str()).await
35
2
}