From ce4f573564cd5fb74d50d647a2c583c38c1c859e Mon Sep 17 00:00:00 2001 From: KoyamaSohei Date: Fri, 7 Feb 2020 01:35:00 +0900 Subject: [PATCH] Fix panic on serving not-exists dir --- static.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/static.go b/static.go index 6463b759..4de39730 100644 --- a/static.go +++ b/static.go @@ -9,6 +9,7 @@ package fiber import ( "log" + "os" "path/filepath" "strings" ) @@ -36,6 +37,11 @@ func (r *Fiber) Static(args ...string) { wildcard = true } + // Check if root exists + if _, err := os.Lstat(root); err != nil { + log.Fatal("Static: ", err) + } + // Lets get all files from root files, _, err := getFiles(root) if err != nil {