Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultConfig = Config{ Skipper: middleware.DefaultSkipper, } )
Functions ¶
func Middleware ¶
func Middleware(ce *casbin.Enforcer, ds DataSource) echo.MiddlewareFunc
Middleware returns a Echo middleware.
func MiddlewareWithConfig ¶
func MiddlewareWithConfig(config Config) echo.MiddlewareFunc
MiddlewareWithConfig returns an Echo middleware with config.
Types ¶
type Config ¶
type Config struct {
// Skipper defines a function to skip middleware.
Skipper middleware.Skipper
// BeforeFunc defines a function which is executed just before the middleware.
BeforeFunc middleware.BeforeFunc
// GetURLPathFunc defines a function which return the requested URL.
GetURLPathFunc func(ctx echo.Context) string
// SuccessHandler defines a function which is executed for a granted access.
SuccessHandler func(echo.Context)
// ErrorHandler defines a function which is executed for a rejected access.
// It may be used to define a custom error.
ErrorHandler func(error, echo.Context) error
// Enforcer instance.
Enforcer *casbin.Enforcer
// DataSource is the interface that extract a subject from echo.Context.
DataSource DataSource
}
Config defines the config for this middleware.
func (*Config) GetSubject ¶
GetSubject extract a subject from the request.
type DataSource ¶
DataSource is the interface that extract a subject from echo.Context.
Click to show internal directories.
Click to hide internal directories.