utoipa_actix_web::scope

Function scope

Source
pub fn scope<I: Into<Scope<T>>, T: ServiceFactory<ServiceRequest, Config = (), Error = Error, InitError = ()>>(
    scope: I,
) -> Scope<T>
Expand description

Create a new Scope with given scope e.g. scope("/api/v1").

This behaves exactly same way as actix_web::Scope but allows automatic schema and path collection from service(...) calls directly or via ServiceConfig::service.

ยงExamples

Create new scoped service.

 #[utoipa::path()]
 #[get("/handler")]
 pub async fn handler() -> &'static str {
     "OK"
 }
let _ = App::new()
    .into_utoipa_app()
    .service(scope::scope("/api/v1/inner").configure(|cfg| {
        cfg.service(handler);
    }));