mid

package
v0.0.0-...-c64bf0e Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 18 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 auth errors.

Functions

func Authenticate

func Authenticate(a *auth.Auth) web.MidHandler

Authenticate validates a JWT from the `Authorization` header.

func Authorize

func Authorize(a *auth.Auth, rule string) web.MidHandler

Authorize executes the specified role and does not extract any domain data.

func AuthorizeHome

func AuthorizeHome(a *auth.Auth, hmeCore *home.Core) web.MidHandler

AuthorizeHome executes the specified role and extracts the specified home from the DB if a home id is specified in the call. Depending on the rule specified, the userid from the claims may be compared with the specified user id from the home.

func AuthorizeProduct

func AuthorizeProduct(a *auth.Auth, prdCore *product.Core) web.MidHandler

AuthorizeProduct executes the specified role and extracts the specified product from the DB if a product id is specified in the call. Depending on the rule specified, the userid from the claims may be compared with the specified user id from the product.

func AuthorizeUser

func AuthorizeUser(a *auth.Auth, usrCore *user.Core) web.MidHandler

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(origins []string) web.MidHandler

Cors sets the response headers needed for Cross-Origin Resource Sharing

func Errors

func Errors(log *logger.Logger) web.MidHandler

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.MidHandler

ExecuteInTransaction starts a transaction around all the storage calls within the scope of the handler function.

func GetHome

func GetHome(ctx context.Context) (home.Home, error)

GetHome returns the home from the context.

func GetProduct

func GetProduct(ctx context.Context) (product.Product, error)

GetProduct returns the product from the context.

func GetUser

func GetUser(ctx context.Context) (user.User, error)

GetUser returns the user from the context.

func GetUserID

func GetUserID(ctx context.Context) (uuid.UUID, error)

GetUserID returns the claims from the context.

func Logger

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

Logger writes information about the request to the logs.

func Metrics

func Metrics() web.MidHandler

Metrics updates program counters.

func Panics

func Panics() web.MidHandler

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