Skip to content

Commit

Permalink
refactor: deprecate path closure
Browse files Browse the repository at this point in the history
  • Loading branch information
nanderstabel committed Aug 30, 2024
1 parent 7599bee commit 805591e
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions agent_api_rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,16 @@ pub struct ApplicationState {
pub verification_state: Option<VerificationState>,
}

pub fn app(state: ApplicationState) -> Router {
let ApplicationState {
pub fn app(
ApplicationState {
issuance_state,
holder_state,
verification_state,
} = state;

let base_path = get_base_path();

let path = |suffix: &str| -> String {
if let Ok(base_path) = &base_path {
format!("/{}{}", base_path, suffix)
} else {
suffix.to_string()
}
};

}: ApplicationState,
) -> Router {
Router::new()
.nest(
&path(Default::default()),
&get_base_path().unwrap_or_default(),
Router::new()
.merge(issuance_state.map(issuance::router).unwrap_or_default())
.merge(holder_state.map(holder::router).unwrap_or_default())
Expand Down Expand Up @@ -89,7 +79,7 @@ fn get_base_path() -> Result<String, ConfigError> {

tracing::info!("Base path: {:?}", base_path);

base_path
format!("/{}", base_path)
})
}

Expand Down

0 comments on commit 805591e

Please sign in to comment.