useragentMiddleware.go 539 B

123456789101112131415161718192021222324
  1. package middleware
  2. import (
  3. "net/http"
  4. )
  5. type UserAgentMiddleware struct {
  6. }
  7. func NewUserAgentMiddleware() *UserAgentMiddleware {
  8. return &UserAgentMiddleware{}
  9. }
  10. func (m *UserAgentMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
  11. return func(w http.ResponseWriter, r *http.Request) {
  12. //val := r.Header.Get("User-Agent")
  13. //reqCtx := r.Context()
  14. //ctx := context.WithValue(reqCtx, "User-Agent", val)
  15. //newReq := r.WithContext(ctx)
  16. //next(w, newReq)
  17. // Pass through to next handler if you need
  18. next(w, r)
  19. }
  20. }