Expected Behavior
I expect the following code two produce two distinct routes:
use std::net::SocketAddr;
use actix_web::{web, App, HttpServer, Responder};
#[actix_web::main]
async fn main() {
let address: SocketAddr = "127.0.0.1:8080".parse().unwrap();
let server = HttpServer::new(move || {
App::new().service(
web::scope("/api/v0").service(
web::scope("/collection")
// FIXME: this routing doesn't work.
// NOTE: switching these two routes doesn't work.
.route("/{uuid}", web::get().to(by_uuid))
.route("/user/{user_name}/{unqualified_id}", web::get().to(by_id)),
),
)
})
.bind(address)
.unwrap();
println!("http://{}", address);
server.run().await.unwrap();
}
pub async fn by_uuid(uuid: web::Path<String>) -> impl Responder {
format!("by UUID: {}", uuid)
}
pub async fn by_id(
user_name: web::Path<String>,
unqualified_id: web::Path<String>,
) -> impl Responder {
format!("by id: {}/{}", user_name, unqualified_id)
}
Current Behavior
However collection/user/{user_name}/{id} route doesn't work:
$ curl 127.0.0.1:8080/api/v0/collection/abc
by UUID: abc # Expected
$ curl 127.0.0.1:8080/api/v0/collection/user/USER/ID
wrong number of parameters: 2 expected 1 # Unexpected
It seem Actix is routing the request to the uuid route and hitting an error.
Steps to Reproduce (for bugs)
- Run the code above.
- Run
curl 127.0.0.1:8080/api/v0/collection/abc, all good.
- Run
curl 127.0.0.1:8080/api/v0/collection/user/USER/ID, hits an error.
Your Environment
- Actix Web Version: 4.0.0-beta.8
Expected Behavior
I expect the following code two produce two distinct routes:
Current Behavior
However
collection/user/{user_name}/{id}route doesn't work:It seem Actix is routing the request to the uuid route and hitting an error.
Steps to Reproduce (for bugs)
curl 127.0.0.1:8080/api/v0/collection/abc, all good.curl 127.0.0.1:8080/api/v0/collection/user/USER/ID, hits an error.Your Environment