aboutsummaryrefslogtreecommitdiff
path: root/weed/server
diff options
context:
space:
mode:
Diffstat (limited to 'weed/server')
-rw-r--r--weed/server/common.go20
-rw-r--r--weed/server/filer_server.go7
-rw-r--r--weed/server/filer_ui/templates.go2
-rw-r--r--weed/server/master_ui/templates.go2
-rw-r--r--weed/server/volume_server.go3
-rw-r--r--weed/server/volume_server_ui/templates.go2
6 files changed, 17 insertions, 19 deletions
diff --git a/weed/server/common.go b/weed/server/common.go
index 12adbf1b4..215ee1036 100644
--- a/weed/server/common.go
+++ b/weed/server/common.go
@@ -12,21 +12,24 @@ import (
"time"
"github.com/chrislusf/seaweedfs/weed/glog"
- "github.com/chrislusf/seaweedfs/weed/images"
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/util"
+
+ _ "github.com/chrislusf/seaweedfs/weed/statik"
+ statik "github.com/rakyll/statik/fs"
)
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) {
@@ -191,14 +194,7 @@ func statsMemoryHandler(w http.ResponseWriter, r *http.Request) {
writeJsonQuiet(w, r, http.StatusOK, m)
}
-func faviconHandler(w http.ResponseWriter, r *http.Request) {
- data, err := images.Asset("favicon/favicon.ico")
- if err != nil {
- glog.V(2).Infoln("favicon read error:", err)
- return
- }
-
- if e := writeResponseContent("favicon.ico", "image/x-icon", bytes.NewReader(data), w, r); e != nil {
- glog.V(2).Infoln("response write error:", e)
- }
+func handleStaticResources(defaultMux *http.ServeMux) {
+ defaultMux.Handle("/favicon.ico", http.FileServer(statikFS))
+ defaultMux.Handle("/seaweedfsstatic/", http.StripPrefix("/seaweedfsstatic", http.FileServer(statikFS)))
}
diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go
index 84e1ea4b8..2aabb9932 100644
--- a/weed/server/filer_server.go
+++ b/weed/server/filer_server.go
@@ -37,6 +37,7 @@ type FilerServer struct {
}
func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption) (fs *FilerServer, err error) {
+
fs = &FilerServer{
option: option,
}
@@ -56,7 +57,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
notification.LoadConfiguration(v.Sub("notification"))
- defaultMux.HandleFunc("/favicon.ico", faviconHandler)
+ handleStaticResources(defaultMux)
defaultMux.HandleFunc("/", fs.filerHandler)
if defaultMux != readonlyMux {
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
@@ -85,8 +86,8 @@ func LoadConfiguration(configFileName string, required bool) {
glog.Errorf("Failed to load %s.toml file from current directory, or $HOME/.seaweedfs/, or /etc/seaweedfs/"+
"\n\nPlease follow this example and add a filer.toml file to "+
"current directory, or $HOME/.seaweedfs/, or /etc/seaweedfs/:\n"+
- " https://github.com/chrislusf/seaweedfs/blob/master/weed/%s.toml\n" +
- "\n\nOr use this command to generate the default toml file\n" +
+ " https://github.com/chrislusf/seaweedfs/blob/master/weed/%s.toml\n"+
+ "\n\nOr use this command to generate the default toml file\n"+
" weed scaffold -config=%s -output=.\n",
configFileName, configFileName, configFileName)
}
diff --git a/weed/server/filer_ui/templates.go b/weed/server/filer_ui/templates.go
index c1454f74c..aad838bf3 100644
--- a/weed/server/filer_ui/templates.go
+++ b/weed/server/filer_ui/templates.go
@@ -44,7 +44,7 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
<div class="container">
<div class="page-header">
<h1>
- <img src="http://7viirv.com1.z0.glb.clouddn.com/seaweed50x50.png"></img>
+ <img src="/seaweedfsstatic/seaweed50x50.png"></img>
SeaweedFS Filer
</h1>
</div>
diff --git a/weed/server/master_ui/templates.go b/weed/server/master_ui/templates.go
index 554ed3a11..3cbc281ea 100644
--- a/weed/server/master_ui/templates.go
+++ b/weed/server/master_ui/templates.go
@@ -15,7 +15,7 @@ var StatusTpl = template.Must(template.New("status").Parse(`<!DOCTYPE html>
<div class="container">
<div class="page-header">
<h1>
- <img src="http://7viirv.com1.z0.glb.clouddn.com/seaweed50x50.png"></img>
+ <img src="/seaweedfsstatic/seaweed50x50.png"></img>
SeaweedFS <small>{{ .Version }}</small>
</h1>
</div>
diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go
index 037fca2c2..01c49da6d 100644
--- a/weed/server/volume_server.go
+++ b/weed/server/volume_server.go
@@ -43,6 +43,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
vs.guard = security.NewGuard(whiteList, "")
+ handleStaticResources(adminMux)
adminMux.HandleFunc("/ui/index.html", vs.uiStatusHandler)
adminMux.HandleFunc("/status", vs.guard.WhiteList(vs.statusHandler))
adminMux.HandleFunc("/admin/assign_volume", vs.guard.WhiteList(vs.assignVolumeHandler))
@@ -64,7 +65,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
adminMux.HandleFunc("/", vs.privateStoreHandler)
if publicMux != adminMux {
// separated admin and public port
- publicMux.HandleFunc("/favicon.ico", faviconHandler)
+ handleStaticResources(publicMux)
publicMux.HandleFunc("/", vs.publicReadOnlyHandler)
}
diff --git a/weed/server/volume_server_ui/templates.go b/weed/server/volume_server_ui/templates.go
index 5f01588f4..d69435a6c 100644
--- a/weed/server/volume_server_ui/templates.go
+++ b/weed/server/volume_server_ui/templates.go
@@ -50,7 +50,7 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC
<div class="container">
<div class="page-header">
<h1>
- <img src="http://7viirv.com1.z0.glb.clouddn.com/seaweed50x50.png"></img>
+ <img src="/seaweedfsstatic/seaweed50x50.png"></img>
SeaweedFS <small>{{ .Version }}</small>
</h1>
</div>