29 lines
595 B
Go
29 lines
595 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/redis/go-redis/v9"
|
|
"net/http"
|
|
)
|
|
|
|
type AuthorityMiddleware struct {
|
|
Rds redis.UniversalClient
|
|
}
|
|
|
|
func NewAuthorityMiddleware(rds redis.UniversalClient) *AuthorityMiddleware {
|
|
return &AuthorityMiddleware{
|
|
Rds: rds,
|
|
}
|
|
}
|
|
|
|
func (m *AuthorityMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
/* // get the path
|
|
obj := r.URL.Path
|
|
// get the method
|
|
act := r.Method
|
|
// get the role id
|
|
roleIds := strings.Split(r.Context().Value("roleId").(string), ",")*/
|
|
next(w, r)
|
|
}
|
|
}
|