Actix-web returning errors

See my question in a comment below:

#[get("/dog/{id}")]
async fn get_dog(req: HttpRequest, state: web::Data<AppState>) -> Result<HttpResponse> {
    let id = req.match_info().get("id").unwrap();
    let dog_map = &state.dog_map;
    if let Some(dog) = dog_map.get(id) {
        Ok(HttpResponse::Ok().json(dog))
    } else {
        // What goes here to return a 404 error?
    }
}
1 Like
Ok(HttpResponse::NotFound().finish())
2 Likes