mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: return 404 on file not found (#18219)
This commit is contained in:
parent
e4c769d072
commit
f833188234
@ -256,6 +256,10 @@ pub fn (mut ctx Context) json_pretty[T](j T) Result {
|
||||
// TODO - test
|
||||
// Response HTTP_OK with file as payload
|
||||
pub fn (mut ctx Context) file(f_path string) Result {
|
||||
if !os.exists(f_path) {
|
||||
eprintln('[vweb] file ${f_path} does not exist')
|
||||
return ctx.not_found()
|
||||
}
|
||||
ext := os.file_ext(f_path)
|
||||
data := os.read_file(f_path) or {
|
||||
eprint(err.msg())
|
||||
|
Loading…
Reference in New Issue
Block a user