diff options
| author | bingoohuang <bingoo.huang@gmail.com> | 2021-04-27 17:22:24 +0800 |
|---|---|---|
| committer | bingoohuang <bingoo.huang@gmail.com> | 2021-04-27 17:22:24 +0800 |
| commit | 7a9d27fce859bc3c7d95a6a98154eab1eb55aa4f (patch) | |
| tree | 702c8ab1710e94c64a64905bec63fb1632b5e4b0 /weed/server | |
| parent | cf552417a7a422d1313c53972fd1175684e758e0 (diff) | |
| download | seaweedfs-7a9d27fce859bc3c7d95a6a98154eab1eb55aa4f.tar.xz seaweedfs-7a9d27fce859bc3c7d95a6a98154eab1eb55aa4f.zip | |
promote to go:embed instead of github.com/rakyll/statik
Diffstat (limited to 'weed/server')
| -rw-r--r-- | weed/server/common.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/weed/server/common.go b/weed/server/common.go index 5c5f1b8eb..571944c10 100644 --- a/weed/server/common.go +++ b/weed/server/common.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "io/fs" "mime/multipart" "net/http" "path/filepath" @@ -21,19 +22,14 @@ import ( "github.com/chrislusf/seaweedfs/weed/util" "github.com/gorilla/mux" - statik "github.com/rakyll/statik/fs" - - _ "github.com/chrislusf/seaweedfs/weed/statik" ) var serverStats *stats.ServerStats var startTime = time.Now() -var statikFS http.FileSystem func init() { serverStats = stats.NewServerStats() go serverStats.Start() - statikFS, _ = statik.New() } func writeJson(w http.ResponseWriter, r *http.Request, httpStatus int, obj interface{}) (err error) { @@ -212,14 +208,16 @@ func statsMemoryHandler(w http.ResponseWriter, r *http.Request) { writeJsonQuiet(w, r, http.StatusOK, m) } +var StaticFS fs.FS + func handleStaticResources(defaultMux *http.ServeMux) { - defaultMux.Handle("/favicon.ico", http.FileServer(statikFS)) - defaultMux.Handle("/seaweedfsstatic/", http.StripPrefix("/seaweedfsstatic", http.FileServer(statikFS))) + defaultMux.Handle("/favicon.ico", http.FileServer(http.FS(StaticFS))) + defaultMux.Handle("/seaweedfsstatic/", http.StripPrefix("/seaweedfsstatic", http.FileServer(http.FS(StaticFS)))) } func handleStaticResources2(r *mux.Router) { - r.Handle("/favicon.ico", http.FileServer(statikFS)) - r.PathPrefix("/seaweedfsstatic/").Handler(http.StripPrefix("/seaweedfsstatic", http.FileServer(statikFS))) + r.Handle("/favicon.ico", http.FileServer(http.FS(StaticFS))) + r.PathPrefix("/seaweedfsstatic/").Handler(http.StripPrefix("/seaweedfsstatic", http.FileServer(http.FS(StaticFS)))) } func adjustHeaderContentDisposition(w http.ResponseWriter, r *http.Request, filename string) { |
