MCPcopy Create free account
hub / github.com/Botloader/botloader / run

Function run

components/webapi/src/lib.rs:34–238  ·  view source on GitHub ↗
(
    common_conf: common::config::RunConfig,
    web_conf: WebConfig,
    setup_tracing_and_metrics: bool,
)

Source from the content-addressed store, hash-verified

32type ApiResult<T> = Result<T, ApiErrorResponse>;
33
34pub async fn run(
35 common_conf: common::config::RunConfig,
36 web_conf: WebConfig,
37 setup_tracing_and_metrics: bool,
38) {
39 if setup_tracing_and_metrics {
40 common::setup_tracing(&common_conf, "webapi");
41 common::setup_metrics("0.0.0.0:7801");
42 }
43
44 let conf = common_conf.clone();
45
46 info!("starting...");
47
48 let state = app_state::init_app_state(&common_conf, &web_conf).await;
49
50 let auth_handler =
51 routes::auth::AuthHandlers::new(state.db.clone(), InMemoryCsrfStore::default());
52
53 let common_middleware_stack = ServiceBuilder::new()
54 .layer(axum_metrics_layer::MetricsLayer {
55 name_prefix: "bl.webapi",
56 })
57 // .layer(Extension(ConfigData {
58 // oauth_client: oatuh_client,
59 // frontend_base: common_conf.frontend_host_base.clone(),
60 // }))
61 .layer(TraceLayer::new_for_http().make_span_with(DefaultMakeSpan::new().level(Level::INFO)))
62 // .layer(Extension(bot_rpc_client))
63 .layer(Extension(Arc::new(auth_handler)))
64 // .layer(Extension(config_store))
65 // .layer(Extension(session_store.clone()))
66 // .layer(Extension(news_handle))
67 // .layer(Extension(discord_config))
68 // .layer(Extension(state_client))
69 .layer(Extension(Arc::new(state.stripe_client.clone())))
70 .layer(axum::middleware::from_fn_with_state(
71 state.clone(),
72 session_mw,
73 ))
74 .layer(CorsLayer {
75 run_config: conf.clone(),
76 });
77
78 let auth_guild_mw_stack = ServiceBuilder::new()
79 .layer(axum::middleware::from_fn(current_guild_injector_middleware))
80 .layer(axum::middleware::from_fn(
81 require_current_guild_admin_middleware,
82 ));
83
84 let authorized_admin_routes = Router::new()
85 .route("/vm_workers", get(routes::admin::get_worker_statuses))
86 .route(
87 "/guild/:guild_id/status",
88 get(routes::admin::get_guild_status),
89 )
90 .layer(axum::middleware::from_fn_with_state(
91 state.clone(),

Callers

nothing calls this directly

Calls 10

setup_tracingFunction · 0.85
setup_metricsFunction · 0.85
init_app_stateFunction · 0.85
postFunction · 0.85
patchFunction · 0.85
deleteFunction · 0.85
putMethod · 0.80
getFunction · 0.50
layerMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected