Skip to content

Commit f833188

Browse files
vweb: return 404 on file not found (#18219)
1 parent e4c769d commit f833188

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

vlib/vweb/vweb.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ pub fn (mut ctx Context) json_pretty[T](j T) Result {
256256
// TODO - test
257257
// Response HTTP_OK with file as payload
258258
pub fn (mut ctx Context) file(f_path string) Result {
259+
if !os.exists(f_path) {
260+
eprintln('[vweb] file ${f_path} does not exist')
261+
return ctx.not_found()
262+
}
259263
ext := os.file_ext(f_path)
260264
data := os.read_file(f_path) or {
261265
eprint(err.msg())

0 commit comments

Comments
 (0)