You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
958 B

11 years ago
  1. package weed_server
  2. import (
  3. "net/http"
  4. "strconv"
  5. "github.com/chrislusf/weed-fs/go/filer"
  6. "github.com/chrislusf/weed-fs/go/glog"
  7. )
  8. type FilerServer struct {
  9. port string
  10. master string
  11. collection string
  12. defaultReplication string
  13. redirectOnRead bool
  14. filer filer.Filer
  15. }
  16. func NewFilerServer(r *http.ServeMux, port int, master string, dir string, collection string,
  17. replication string, redirectOnRead bool,
  18. ) (fs *FilerServer, err error) {
  19. fs = &FilerServer{
  20. master: master,
  21. collection: collection,
  22. defaultReplication: replication,
  23. redirectOnRead: redirectOnRead,
  24. port: ":" + strconv.Itoa(port),
  25. }
  26. if fs.filer, err = filer.NewFilerEmbedded(master, dir); err != nil {
  27. glog.Fatal("Can not start filer in dir", dir, ": ", err.Error())
  28. return
  29. }
  30. r.HandleFunc("/admin/mv", fs.moveHandler)
  31. r.HandleFunc("/", fs.filerHandler)
  32. return fs, nil
  33. }