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.

41 lines
1023 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/filer/embedded_filer"
  7. "github.com/chrislusf/weed-fs/go/glog"
  8. )
  9. type FilerServer struct {
  10. port string
  11. master string
  12. collection string
  13. defaultReplication string
  14. redirectOnRead bool
  15. filer filer.Filer
  16. }
  17. func NewFilerServer(r *http.ServeMux, port int, master string, dir string, collection string,
  18. replication string, redirectOnRead bool,
  19. ) (fs *FilerServer, err error) {
  20. fs = &FilerServer{
  21. master: master,
  22. collection: collection,
  23. defaultReplication: replication,
  24. redirectOnRead: redirectOnRead,
  25. port: ":" + strconv.Itoa(port),
  26. }
  27. if fs.filer, err = embedded_filer.NewFilerEmbedded(master, dir); err != nil {
  28. glog.Fatal("Can not start filer in dir", dir, ": ", err.Error())
  29. return
  30. }
  31. r.HandleFunc("/admin/mv", fs.moveHandler)
  32. r.HandleFunc("/", fs.filerHandler)
  33. return fs, nil
  34. }