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.

32 lines
683 B

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