You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the with_*() functions for Response all have different error-behavior:
with_json() panics on serialization failure.
with_asset() will instead not panic, continue to execute and return a 404 upon attempting to retrieve the asset. This is the same behavior as if the route isn't even defined. Very confusing.
with_file() is the same as with_asset() except that if there is an error opening the file a 500 code with the actual error embedded is returned instead of a 404.
I think it should either be all panic, all returning a 500 with the included error text, a result be propagated somehow or the error message be printed in the "log". 404s are very confusing when the file you are trying to include doesn't exist as it looks like the route doesn't exist instead of the file not existing.
Minimum confusing example:
use vial::{routes, run};routes!{GET"/file" => |_| Response::from_file("I DO NOT EXIST");}fnmain(){
_ = run!();}
Output after two curls:
~ vial running at http://0.0.0.0:7667
GET 404 /file
GET 404 /route_not_existo
The text was updated successfully, but these errors were encountered:
Currently the
with_*()
functions forResponse
all have different error-behavior:with_json()
panics on serialization failure.with_asset()
will instead not panic, continue to execute and return a 404 upon attempting to retrieve the asset. This is the same behavior as if the route isn't even defined. Very confusing.with_file()
is the same aswith_asset()
except that if there is an error opening the file a 500 code with the actual error embedded is returned instead of a 404.I think it should either be all panic, all returning a 500 with the included error text, a result be propagated somehow or the error message be printed in the "log". 404s are very confusing when the file you are trying to include doesn't exist as it looks like the route doesn't exist instead of the file not existing.
Minimum confusing example:
Output after two curls:
~ vial running at http://0.0.0.0:7667 GET 404 /file GET 404 /route_not_existo
The text was updated successfully, but these errors were encountered: