volume_server_handlers.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package weed_server
  2. import (
  3. "net/http"
  4. "github.com/chrislusf/seaweedfs/weed/stats"
  5. )
  6. /*
  7. If volume server is started with a separated public port, the public port will
  8. be more "secure".
  9. Public port currently only supports reads.
  10. Later writes on public port can have one of the 3
  11. security settings:
  12. 1. not secured
  13. 2. secured by white list
  14. 3. secured by JWT(Json Web Token)
  15. */
  16. func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Request) {
  17. switch r.Method {
  18. case "GET":
  19. stats.ReadRequest()
  20. vs.GetOrHeadHandler(w, r)
  21. case "HEAD":
  22. stats.ReadRequest()
  23. vs.GetOrHeadHandler(w, r)
  24. case "DELETE":
  25. stats.DeleteRequest()
  26. vs.guard.WhiteList(vs.DeleteHandler)(w, r)
  27. case "PUT":
  28. stats.WriteRequest()
  29. vs.guard.WhiteList(vs.PostHandler)(w, r)
  30. case "POST":
  31. stats.WriteRequest()
  32. vs.guard.WhiteList(vs.PostHandler)(w, r)
  33. }
  34. }
  35. func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Request) {
  36. switch r.Method {
  37. case "GET":
  38. stats.ReadRequest()
  39. vs.GetOrHeadHandler(w, r)
  40. case "HEAD":
  41. stats.ReadRequest()
  42. vs.GetOrHeadHandler(w, r)
  43. }
  44. }
  45. func (vs *VolumeServer) faviconHandler(w http.ResponseWriter, r *http.Request) {
  46. vs.FaviconHandler(w, r)
  47. }