Report 404 instead of 502 when a snapshot file is not found
This provides the client with more useful information about why their request failed
This commit is contained in:
@ -164,7 +164,11 @@ impl RpcRequestMiddleware {
|
|||||||
should_validate_hosts: true,
|
should_validate_hosts: true,
|
||||||
response: Box::pin(async {
|
response: Box::pin(async {
|
||||||
match Self::open_no_follow(filename).await {
|
match Self::open_no_follow(filename).await {
|
||||||
Err(_) => Ok(Self::internal_server_error()),
|
Err(err) => Ok(if err.kind() == std::io::ErrorKind::NotFound {
|
||||||
|
Self::not_found()
|
||||||
|
} else {
|
||||||
|
Self::internal_server_error()
|
||||||
|
}),
|
||||||
Ok(file) => {
|
Ok(file) => {
|
||||||
let stream =
|
let stream =
|
||||||
FramedRead::new(file, BytesCodec::new()).map_ok(|b| b.freeze());
|
FramedRead::new(file, BytesCodec::new()).map_ok(|b| b.freeze());
|
||||||
|
Reference in New Issue
Block a user