actix / actix/actix-web

Multiple `.service(` doesn't merge route patterns

Abierto
#3,778 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
24.8k
Forks
1.9k
Merge medio
23 h 10 min
PR fusionados (30 d)
26

Descripción

## Expected Behavior

I'm building a nice size Apache-2.0 OR MIT) application. Reads are insecure, writes are secured. Here's my server:

```rs
.service(
utoipa_actix_web::scope("/api/v0")
.wrap(actix_web::middleware::Compat::new(
actix_web_httpauth::middleware::HttpAuthentication::bearer(
rust_actix_diesel_auth_scaffold::middleware::bearer::validator,
),
))
/* Org */
.service(crawlcomply_backend::routes::org::upsert)
.service(crawlcomply_backend::routes::org::remove)
)
.service(
utoipa_actix_web::scope("/api/v0")
/* Org */
.service(crawlcomply_backend::routes::org::read_many)
)
```

## Current Behavior

`POST /api/v0/org` works, whereas `GET /api/v0/org` never hits the route function.

## Possible Solution

Merge routes

## Steps to Reproduce (for bugs)

```rs
actix_web::HttpServer::new(move || {
actix_web::App::new()
.into_utoipa_app()
.openapi(ApiDoc::openapi())
.map(|app| app.wrap(actix_web::middleware::Logger::default()))
.app_data(
actix_web::web::JsonConfig::default().error_handler(|err, _req| {
actix_web::error::InternalError::from_response(
"",
actix_web::HttpResponse::BadRequest()
.content_type("application/json")
.body(format!(r#"{{"error":"{}"}}"#, err)),
)
.into()
}),
)
.app_data(actix_web::web::Data::new(pool.clone()))
.service(
utoipa_actix_web::scope("/api/v0")
.wrap(actix_web::middleware::Compat::new(
actix_web_httpauth::middleware::HttpAuthentication::bearer(
rust_actix_diesel_auth_scaffold::middleware::bearer::validator,
),
))
/* Org */
.service(crawlcomply_backend::routes::org::upsert)
.service(crawlcomply_backend::routes::org::remove)
)
.service(
utoipa_actix_web::scope("/api/v0")
/* Org */
.service(crawlcomply_backend::routes::org::read)
.service(crawlcomply_backend::routes::org::read_many)
)
.openapi_service(|api| utoipa_scalar::Scalar::with_url("/scalar", api))
.into_app()
})
.bind((args.hostname.as_str(), args.port))?
.run()
.await
```

## Context

Trying to have one group of routes be authenticated only and another group of routes public.

## Your Environment

- Rust Version (I.e, output of `rustc -V`): rustc 1.92.0-nightly (caccb4d03 2025-09-24)
- Actix Web Version: 4.11.0

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.