mid

package
v0.0.0-...-c2300e3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package mid contains the set of middleware functions.

Index

Constants

This section is empty.

Variables

View Source
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

func AuthorizeProperty(a *auth.Auth, rule string, prprtyCore *property.Core) web.Middleware

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

func AuthorizeUser(a *auth.Auth, rule string, usrCore *user.Core) web.Middleware

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 GetProperty

func GetProperty(ctx context.Context) property.Property

func GetUser

func GetUser(ctx context.Context) user.User

func GetUserID

func GetUserID(ctx context.Context) uuid.UUID

func Logger

func Logger(log *logger.Logger) web.Middleware

Logger writes information about the request to the logs.

func Metrics

func Metrics() web.Middleware

Metrics updates program counters.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL