mirror of
https://github.com/linka-cloud/grpc.git
synced 2024-12-24 18:00:46 +00:00
react handler: check if there is an html file
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
e5d84975a2
commit
828bf008ca
@ -41,8 +41,13 @@ func newStatic(dir fs.FS, subpath string) (http.Handler, error) {
|
||||
}
|
||||
fsrv := http.FileServer(http.FS(s))
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if _, err := fs.Stat(s, strings.TrimPrefix(r.URL.Path, "/")); err != nil {
|
||||
r.URL.Path = "/"
|
||||
p := strings.TrimPrefix(r.URL.Path, "/")
|
||||
if _, err := fs.Stat(s, p); err != nil {
|
||||
if _, err := fs.Stat(s, p+".html"); err == nil {
|
||||
r.URL.Path += ".html"
|
||||
} else {
|
||||
r.URL.Path = "/"
|
||||
}
|
||||
}
|
||||
fsrv.ServeHTTP(w, r)
|
||||
}), nil
|
||||
|
Loading…
Reference in New Issue
Block a user