aboutsummaryrefslogtreecommitdiff
path: root/weed/server/common.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-05-10 00:13:55 -0700
committerChris Lu <chris.lu@gmail.com>2021-05-10 00:13:55 -0700
commitda0a4e775bcb7cbef3ea4fd5592d0a8cee436d92 (patch)
treec22f3cd42ac133fc905c30a209e364e5ca7fec19 /weed/server/common.go
parent40945a60cfddde46ccf2c6f7c6f9170d61fde959 (diff)
downloadseaweedfs-da0a4e775bcb7cbef3ea4fd5592d0a8cee436d92.tar.xz
seaweedfs-da0a4e775bcb7cbef3ea4fd5592d0a8cee436d92.zip
Revert "Revert "Merge pull request #2027 from bingoohuang/master""
This reverts commit d74cdf011553ae073d524a080f65f418c76ccaa7.
Diffstat (limited to 'weed/server/common.go')
-rw-r--r--weed/server/common.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/weed/server/common.go b/weed/server/common.go
index 9001a3b33..7882109e5 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) {