Documentation ¶
Overview ¶
Package mid contains the set of middleware functions.
Index ¶
- Variables
- func Authenticate(a *auth.Auth) web.Middleware
- func Authorize(a *auth.Auth, rule string) web.Middleware
- func AuthorizeProperty(a *auth.Auth, rule string, prprtyCore *property.Core) web.Middleware
- func AuthorizeUser(a *auth.Auth, rule string, usrCore *user.Core) web.Middleware
- func Cors(origin string) web.Middleware
- func Errors(log *logger.Logger) web.Middleware
- func ExecuteInTransaction(log *logger.Logger, bgn transaction.Beginner) web.Middleware
- func GetProperty(ctx context.Context) property.Property
- func GetUser(ctx context.Context) user.User
- func GetUserID(ctx context.Context) uuid.UUID
- func Logger(log *logger.Logger) web.Middleware
- func Metrics() web.Middleware
- func Panics() web.Middleware
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidID = errors.New("ID is not in its proper form")
)
Set of error variables for handling user group errors.
Functions ¶
func Authenticate ¶
func Authenticate(a *auth.Auth) web.Middleware
Authenticate validates a JWT from the `Authorization` header.
func Authorize ¶
func Authorize(a *auth.Auth, rule string) web.Middleware
Authorize executes the specified role and does not extract any domain data.
func AuthorizeProperty ¶
AuthorizeProperty executes the specified role and extracts the specified property from the DB if a property id is specified in the call. Depending on the rule specified, the userid from the claims may be compared with the specified manager id from the property.
func AuthorizeUser ¶
AuthorizeUser executes the specified role and extracts the specified user from the DB if a user id is specified in the call. Depending on the rule specified, the userid from the claims may be compared with the specified user id.
func Cors ¶
func Cors(origin string) web.Middleware
Cors sets the response headers needed for Cross-Origin Resource Sharing
func Errors ¶
func Errors(log *logger.Logger) web.Middleware
Errors handles errors coming out of the call chain. It detects normal application errors which are used to respond to the client in a uniform way. Unexpected errors (status >= 500) are logged.
func ExecuteInTransaction ¶
func ExecuteInTransaction(log *logger.Logger, bgn transaction.Beginner) web.Middleware
ExecuteInTransaction starts a transaction around all the storage calls within the scope of the handler function.
func Logger ¶
func Logger(log *logger.Logger) web.Middleware
Logger writes information about the request to the logs.
func Panics ¶
func Panics() web.Middleware
Panics recovers from panics and converts the panic to an error so it is reported in Metrics and handled in Errors.
Types ¶
This section is empty.