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.

64 lines
1.4 KiB

  1. package weed_server
  2. import (
  3. "net/http"
  4. "github.com/chrislusf/weed-fs/go/stats"
  5. )
  6. /*
  7. Public port supports reads. Writes on public port can have one of the 3
  8. security settings:
  9. 1. not secured
  10. 2. secured by white list
  11. 3. secured by JWT(Json Web Token)
  12. If volume server is started with a separated admin port, the admin port will
  13. have less "security" for easier implementation.
  14. Admin port always supports reads. Writes on admin port can have one of
  15. the 2 security settings:
  16. 1. not secured
  17. 2. secured by white list
  18. */
  19. func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Request) {
  20. switch r.Method {
  21. case "GET":
  22. stats.ReadRequest()
  23. vs.GetOrHeadHandler(w, r)
  24. case "HEAD":
  25. stats.ReadRequest()
  26. vs.GetOrHeadHandler(w, r)
  27. case "DELETE":
  28. stats.DeleteRequest()
  29. vs.guard.WhiteList(vs.DeleteHandler)(w, r)
  30. case "PUT":
  31. stats.WriteRequest()
  32. vs.guard.WhiteList(vs.PostHandler)(w, r)
  33. case "POST":
  34. stats.WriteRequest()
  35. vs.guard.WhiteList(vs.PostHandler)(w, r)
  36. }
  37. }
  38. func (vs *VolumeServer) publicStoreHandler(w http.ResponseWriter, r *http.Request) {
  39. switch r.Method {
  40. case "GET":
  41. stats.ReadRequest()
  42. vs.GetOrHeadHandler(w, r)
  43. case "HEAD":
  44. stats.ReadRequest()
  45. vs.GetOrHeadHandler(w, r)
  46. case "DELETE":
  47. stats.DeleteRequest()
  48. vs.guard.Secure(vs.DeleteHandler)(w, r)
  49. case "PUT":
  50. stats.WriteRequest()
  51. vs.guard.Secure(vs.PostHandler)(w, r)
  52. case "POST":
  53. stats.WriteRequest()
  54. vs.guard.Secure(vs.PostHandler)(w, r)
  55. }
  56. }