admin: fix static routing
This commit is contained in:
parent
db2e286677
commit
c9e4d3e27c
2 changed files with 23 additions and 5 deletions
|
|
@ -2,8 +2,17 @@ package main
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"path"
|
||||
)
|
||||
|
||||
func StaticRouting(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "./static/index.html")
|
||||
type staticRouting struct{
|
||||
StaticDir string
|
||||
}
|
||||
|
||||
func StaticHandler(staticDir string) http.Handler {
|
||||
return staticRouting{staticDir}
|
||||
}
|
||||
|
||||
func (a staticRouting) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, path.Join(a.StaticDir, "index.html"))
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue