MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / run_external_api

Function run_external_api

vmm/src/main.rs:77–109  ·  view source on GitHub ↗
(app: App, figment: Figment, api_auth: ApiToken)

Source from the content-addressed store, hash-verified

75}
76
77async fn run_external_api(app: App, figment: Figment, api_auth: ApiToken) -> Result<()> {
78 let version = app_version();
79 let openapi_doc = openapi::build_openapi_doc(&version)?;
80
81 let external_api = rocket::custom(figment)
82 .mount("/", main_routes::routes())
83 .mount("/guest", ra_rpc::prpc_routes!(App, GuestApiHandler))
84 .mount("/api", ra_rpc::prpc_routes!(App, HostApiHandler))
85 .mount(
86 "/prpc",
87 ra_rpc::prpc_routes!(App, RpcHandler, trim: "Teepod."),
88 )
89 .manage(app)
90 .manage(api_auth)
91 .attach(AdHoc::on_response("Add app rev header", |_req, res| {
92 Box::pin(async move {
93 res.set_raw_header("X-App-Version", app_version());
94 })
95 }))
96 .attach(AdHoc::on_response("Disable buffering", |_req, res| {
97 Box::pin(async move {
98 res.set_raw_header("X-Accel-Buffering", "no");
99 })
100 }));
101 let external_api =
102 ra_rpc::rocket_helper::mount_openapi_docs(external_api, openapi_doc, "/api-docs");
103
104 let _ = external_api
105 .launch()
106 .await
107 .map_err(|err| anyhow!(err.to_string()))?;
108 Ok(())
109}
110
111async fn run_host_api(app: App, figment: Figment) -> Result<()> {
112 let figment = figment

Callers

nothing calls this directly

Calls 4

mount_openapi_docsFunction · 0.85
app_versionFunction · 0.70
build_openapi_docFunction · 0.70
routesFunction · 0.70

Tested by

no test coverage detected