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.

51 lines
1.8 KiB

4 years ago
6 years ago
4 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
4 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. package weed_server
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/util"
  4. "net/http"
  5. "time"
  6. "github.com/chrislusf/seaweedfs/weed/stats"
  7. )
  8. func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
  9. w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
  10. start := time.Now()
  11. switch r.Method {
  12. case "GET":
  13. stats.FilerRequestCounter.WithLabelValues("get").Inc()
  14. fs.GetOrHeadHandler(w, r, true)
  15. stats.FilerRequestHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds())
  16. case "HEAD":
  17. stats.FilerRequestCounter.WithLabelValues("head").Inc()
  18. fs.GetOrHeadHandler(w, r, false)
  19. stats.FilerRequestHistogram.WithLabelValues("head").Observe(time.Since(start).Seconds())
  20. case "DELETE":
  21. stats.FilerRequestCounter.WithLabelValues("delete").Inc()
  22. fs.DeleteHandler(w, r)
  23. stats.FilerRequestHistogram.WithLabelValues("delete").Observe(time.Since(start).Seconds())
  24. case "PUT":
  25. stats.FilerRequestCounter.WithLabelValues("put").Inc()
  26. fs.PostHandler(w, r)
  27. stats.FilerRequestHistogram.WithLabelValues("put").Observe(time.Since(start).Seconds())
  28. case "POST":
  29. stats.FilerRequestCounter.WithLabelValues("post").Inc()
  30. fs.PostHandler(w, r)
  31. stats.FilerRequestHistogram.WithLabelValues("post").Observe(time.Since(start).Seconds())
  32. }
  33. }
  34. func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Request) {
  35. w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)
  36. start := time.Now()
  37. switch r.Method {
  38. case "GET":
  39. stats.FilerRequestCounter.WithLabelValues("get").Inc()
  40. fs.GetOrHeadHandler(w, r, true)
  41. stats.FilerRequestHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds())
  42. case "HEAD":
  43. stats.FilerRequestCounter.WithLabelValues("head").Inc()
  44. fs.GetOrHeadHandler(w, r, false)
  45. stats.FilerRequestHistogram.WithLabelValues("head").Observe(time.Since(start).Seconds())
  46. }
  47. }