Path parsing error handling #1986
Answered
by
robjtede
michalsieron
asked this question in
Q&A
-
Given this code: use actix_web::{get, web, App, HttpResponse, HttpServer};
use uuid::Uuid;
#[get("/{uid}")]
async fn sample(uid: web::Path<Uuid>) -> HttpResponse {
HttpResponse::Ok().finish()
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().service(sample))
.bind("localhost:8080")?
.run()
.await
} and this dependencies: [dependencies]
actix-web = "3.3.2"
uuid = { version = "0.8.2", features = ["serde"] } how can I handle cases when path parameter For example:
And I am talking specifically about this last line |
Beta Was this translation helpful? Give feedback.
Answered by
robjtede
Feb 12, 2021
Replies: 1 comment 2 replies
-
using |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
michalsieron
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using
uid: Option<web::Path<Uuid>>
will let you handle it how you want