{{#each operations as |operation|}} use crate::dto::request::{{upper_camel operation.operationId}}Request; {{/each}} {{#each operations as |operation|}} use crate::server::handler::{{upper_camel operation.operationId}}Trait; {{/each}} use argentum_rest_infrastructure::data_type::error::HttpError; use argentum_rest_infrastructure::data_type::{HttpResponse, RequestTrait}; use argentum_rest_infrastructure::service::{ {{#if securityEnabled}} BearerAuthenticator, {{/if}} RequestTransformer }; use std::collections::HashMap; use std::sync::Arc; pub struct PreHandler { request_transformer: Arc, {{#if securityEnabled}} bearer_auth: Arc, {{/if}} {{#each operations as |operation|}} {{snake operation.operationId}}: Arc, {{/each}} } impl PreHandler { pub fn new( request_transformer: Arc, {{#if securityEnabled}} bearer_auth: Arc, {{/if}} {{#each operations as |operation|}} {{snake operation.operationId}}: Arc, {{/each}} ) -> Self { Self { request_transformer, {{#if securityEnabled}} bearer_auth, {{/if}} {{#each operations as |operation|}} {{snake operation.operationId}}, {{/each}} } } {{#each operations as |operation|}} pub async fn {{snake operation.operationId}}( &self, request: impl RequestTrait, raw_path_params: HashMap<&str, &str>, ) -> Result { let raw_query_params = HashMap::from([]); let req: {{upper_camel operation.operationId}}Request = self .request_transformer .transform(request, raw_path_params, raw_query_params) .await?; {{#if operation.security}} let user = self.bearer_auth.auth(&req.params.headers)?; let r = self.{{snake operation.operationId}}.handle(req, user)?; {{else}} let r = self.{{snake operation.operationId}}.handle(req)?; {{/if}} Ok(HttpResponse::new(r.to_status_code(), r.to_response().body())) } {{/each}} }