-
Hello actix community I've started to write a very small application using actix and I have the following issue that I don't understand How can I have wildcard/dynamic path parameters (don't know how exactly to call it) so I can call the endpoint with a variable number of parameters? Hope I explained it good enough my code so far looks like this use actix_web::{get, web, HttpResponse, Responder};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Image {
width: Option<String>,
height: Option<String>,
filename: Option<String>,
}
// I want to get rid of the width, height, filename segments and have something like * to catch all the params
#[get("/images/{width}/{height}/{filename}")]
async fn show(params: web::Path<Image>) -> impl Responder {
println!("{:?}", params);
HttpResponse::Ok().json("foo")
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ok, I managed to find the solution in the documentation. I didn't saw it while reading the docs :D // this will catch all the url parameters
#[get("/images/{tail:.*}")]
async fn show(params: web::Path<String>) -> impl Responder {
println!("{:?}", params);
HttpResponse::Ok().json("foo")
} |
Beta Was this translation helpful? Give feedback.
Ok, I managed to find the solution in the documentation. I didn't saw it while reading the docs :D