seaweedfs/go/weed/weed_server/filer_server.go

41 lines
964 B
Go
Raw Normal View History

2014-03-31 02:28:04 +08:00
package weed_server
import (
"net/http"
2014-03-31 11:57:25 +08:00
"strconv"
2014-12-14 16:20:21 +08:00
"github.com/mcqueenorama/weed-fs/go/filer"
"github.com/mcqueenorama/weed-fs/go/glog"
2014-03-31 02:28:04 +08:00
)
type FilerServer struct {
port string
master string
collection string
defaultReplication string
redirectOnRead bool
filer filer.Filer
2014-03-31 02:28:04 +08:00
}
func NewFilerServer(r *http.ServeMux, port int, master string, dir string, collection string,
replication string, redirectOnRead bool,
) (fs *FilerServer, err error) {
2014-03-31 02:28:04 +08:00
fs = &FilerServer{
master: master,
collection: collection,
defaultReplication: replication,
redirectOnRead: redirectOnRead,
port: ":" + strconv.Itoa(port),
2014-03-31 02:28:04 +08:00
}
if fs.filer, err = filer.NewFilerEmbedded(master, dir); err != nil {
glog.Fatal("Can not start filer in dir", dir, ": ", err.Error())
2014-03-31 02:28:04 +08:00
return
}
r.HandleFunc("/admin/mv", fs.moveHandler)
2014-03-31 02:28:04 +08:00
r.HandleFunc("/", fs.filerHandler)
return fs, nil
}