123456789101112131415161718192021222324 |
- package middleware
- import (
- "net/http"
- )
- type UserAgentMiddleware struct {
- }
- func NewUserAgentMiddleware() *UserAgentMiddleware {
- return &UserAgentMiddleware{}
- }
- func (m *UserAgentMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- //val := r.Header.Get("User-Agent")
- //reqCtx := r.Context()
- //ctx := context.WithValue(reqCtx, "User-Agent", val)
- //newReq := r.WithContext(ctx)
- //next(w, newReq)
- // Pass through to next handler if you need
- next(w, r)
- }
- }
|