mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
41 lines
964 B
Go
41 lines
964 B
Go
package weed_server
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/mcqueenorama/weed-fs/go/filer"
|
|
"github.com/mcqueenorama/weed-fs/go/glog"
|
|
)
|
|
|
|
type FilerServer struct {
|
|
port string
|
|
master string
|
|
collection string
|
|
defaultReplication string
|
|
redirectOnRead bool
|
|
filer filer.Filer
|
|
}
|
|
|
|
func NewFilerServer(r *http.ServeMux, port int, master string, dir string, collection string,
|
|
replication string, redirectOnRead bool,
|
|
) (fs *FilerServer, err error) {
|
|
fs = &FilerServer{
|
|
master: master,
|
|
collection: collection,
|
|
defaultReplication: replication,
|
|
redirectOnRead: redirectOnRead,
|
|
port: ":" + strconv.Itoa(port),
|
|
}
|
|
|
|
if fs.filer, err = filer.NewFilerEmbedded(master, dir); err != nil {
|
|
glog.Fatal("Can not start filer in dir", dir, ": ", err.Error())
|
|
return
|
|
}
|
|
|
|
r.HandleFunc("/admin/mv", fs.moveHandler)
|
|
r.HandleFunc("/", fs.filerHandler)
|
|
|
|
return fs, nil
|
|
}
|