You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oa/internal/middleware/authmiddleware.go

26 lines
562 B
Go

package middleware
import (
"context"
"net/http"
)
type AuthMiddleware struct {
ID string `json:"id"`
}
func NewAuthMiddleware() *AuthMiddleware {
return &AuthMiddleware{}
}
func (m *AuthMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// TODO generate middleware implement function, delete after code implementation
// Passthrough to next handler if need
// val := r.Header.Get("User-Agent")
ctx := context.WithValue(r.Context(), "u", "123")
next(w, r.WithContext(ctx))
}
}