-
When I tried to use this route, then actix properly returned code 200 for get #[get("/patient-info/")]
pub async fn AAAA(
pool: web::Data<DbPool>,
) -> anyhow::Result<HttpResponse, Error> {
Ok(HttpResponse::Ok().body("ABCD"))
} but when I used this one, then same get returned 404 #[get("/patient-info/{eye}")]
pub async fn AAAA(
pool: web::Data<DbPool>,
path: web::Json<Option<String>>,
) -> anyhow::Result<HttpResponse, Error> {
Ok(HttpResponse::Ok().body("ABCD"))
} How can I get eye value(can be none if request is |
Beta Was this translation helpful? Give feedback.
Answered by
robjtede
Sep 14, 2022
Replies: 1 comment 2 replies
-
#[get("/patient-info/{eye}")]
pub async fn AAAA(
pool: web::Data<DbPool>,
path: web::Path<String>,
) -> anyhow::Result<HttpResponse, Error> {
Ok(HttpResponse::Ok().body("ABCD"))
} Though #[get("/patient-info")]
pub async fn aaa(
pool: web::Data<DbPool>,
path: web::Path<String>,
) -> Result<HttpResponse, Error> {
aaaa_inner(&pool, None)
}
#[get("/patient-info/{eye}")]
pub async fn aaaa_eye(
pool: web::Data<DbPool>,
path: web::Path<String>,
) -> Result<HttpResponse, Error> {
aaaa_inner(&pool, Some(path.into_inner()))
}
async fn aaaa_inner(pool: &DbPool, path: Option<String>) -> Result<HttpResponse, Error> {
...
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
qarmin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Though
Option<String>
will not work here. You'll need two handlers and a delegate method. Eg: