Honor the useStaticDirectory variable in the static handler to minimize unnecessary os.Stat
This commit is contained in:
parent
1cf9318bc8
commit
63f484e269
1 changed files with 8 additions and 3 deletions
11
pkg.go
11
pkg.go
|
@ -305,9 +305,14 @@ func (service *Service) StaticHandler(w http.ResponseWriter, r *http.Request, se
|
|||
|
||||
r.URL.Path = fmt.Sprintf("/%s/%s", comp[1], comp[2])
|
||||
p := fmt.Sprintf(service.staticDirectory+"/%s/%s", comp[1], comp[2])
|
||||
_, err = os.Stat(p)
|
||||
if err == nil {
|
||||
service.staticLocalFileserver.ServeHTTP(w, r)
|
||||
|
||||
if service.useStaticDirectory {
|
||||
_, err = os.Stat(p)
|
||||
if err == nil {
|
||||
service.staticLocalFileserver.ServeHTTP(w, r)
|
||||
} else {
|
||||
service.staticEmbeddedFileserver.ServeHTTP(w, r)
|
||||
}
|
||||
} else {
|
||||
service.staticEmbeddedFileserver.ServeHTTP(w, r)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue