MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / start

Function start

examples/rocket_okapi_example/api/src/lib.rs:34–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33#[tokio::main]
34async fn start() -> Result<(), rocket::Error> {
35 let mut building_rocket = rocket::build()
36 .attach(Db::init())
37 .attach(AdHoc::try_on_ignite("Migrations", run_migrations))
38 .mount(
39 "/swagger-ui/",
40 make_swagger_ui(&SwaggerUIConfig {
41 url: "../v1/openapi.json".to_owned(),
42 ..Default::default()
43 }),
44 )
45 .mount(
46 "/rapidoc/",
47 make_rapidoc(&RapiDocConfig {
48 title: Some("Rocket/SeaOrm - RapiDoc documentation | RapiDoc".to_owned()),
49 general: GeneralConfig {
50 spec_urls: vec![UrlObject::new("General", "../v1/openapi.json")],
51 ..Default::default()
52 },
53 hide_show: HideShowConfig {
54 allow_spec_url_load: false,
55 allow_spec_file_load: false,
56 ..Default::default()
57 },
58 ..Default::default()
59 }),
60 )
61 .attach(cors());
62
63 let openapi_settings = rocket_okapi::settings::OpenApiSettings::default();
64 let custom_route_spec = (vec![], custom_openapi_spec());
65 mount_endpoints_and_merged_docs! {
66 building_rocket, "/v1".to_owned(), openapi_settings,
67 "/additional" => custom_route_spec,
68 "/okapi-example" => okapi_example::get_routes_and_docs(&openapi_settings),
69 };
70
71 building_rocket.launch().await.map(|_| ())
72}
73
74fn cors() -> Cors {
75 let allowed_origins =

Callers 1

mainFunction · 0.70

Calls 3

initFunction · 0.85
corsFunction · 0.85
custom_openapi_specFunction · 0.85

Tested by

no test coverage detected