Documentation ¶
Overview ¶
Package mid provides context support.
Index ¶
- Variables
- func Basic(ctx context.Context, ath *auth.Auth, userBus *userbus.Business, ...) (eauth.UID, *auth.Claims, error)
- func Bearer(ctx context.Context, ath *auth.Auth, authorization string) (eauth.UID, *auth.Claims, error)
- func BeginCommitRollback(log *logger.Logger, bgn sqldb.Beginner, req middleware.Request, ...) middleware.Response
- func GetHome(ctx context.Context) (homebus.Home, error)
- func GetProduct(ctx context.Context) (productbus.Product, error)
- func GetTran(ctx context.Context) (sqldb.CommitRollbacker, error)
- func GetUser(ctx context.Context) (userbus.User, error)
- func GetUserID(ctx context.Context) (uuid.UUID, error)
- func Metrics(v *metrics.Values, req middleware.Request, next middleware.Next) middleware.Response
- func Panics(v *metrics.Values, req middleware.Request, next middleware.Next) (resp middleware.Response)
- type AuthInfo
- func Authorize(req middleware.Request) (AuthInfo, middleware.Request, error)
- func AuthorizeHome(homeBus *homebus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)
- func AuthorizeProduct(productBus *productbus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)
- func AuthorizeUser(userBus *userbus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidID = errors.New("ID is not in its proper form")
ErrInvalidID represents a condition where the id is not a uuid.
Functions ¶
func Basic ¶
func Basic(ctx context.Context, ath *auth.Auth, userBus *userbus.Business, authorization string) (eauth.UID, *auth.Claims, error)
Basic processes basic authentication logic.
func Bearer ¶
func Bearer(ctx context.Context, ath *auth.Auth, authorization string) (eauth.UID, *auth.Claims, error)
Bearer processes JWT authentication logic.
func BeginCommitRollback ¶
func BeginCommitRollback(log *logger.Logger, bgn sqldb.Beginner, req middleware.Request, next middleware.Next) middleware.Response
BeginCommitRollback starts a transaction for the domain call.
func GetProduct ¶
func GetProduct(ctx context.Context) (productbus.Product, error)
GetProduct returns the product from the context.
func GetTran ¶
func GetTran(ctx context.Context) (sqldb.CommitRollbacker, error)
GetTran retrieves the value that can manage a transaction.
func Metrics ¶
func Metrics(v *metrics.Values, req middleware.Request, next middleware.Next) middleware.Response
Metrics sets the basic counters and guages.
func Panics ¶
func Panics(v *metrics.Values, req middleware.Request, next middleware.Next) (resp middleware.Response)
Panics handles panics that occur when processing a request.
Types ¶
type AuthInfo ¶
AuthInfo defines the information required to perform an authorization.
func Authorize ¶
func Authorize(req middleware.Request) (AuthInfo, middleware.Request, error)
Authorize checks the user making the request is an admin or user.
func AuthorizeHome ¶
func AuthorizeHome(homeBus *homebus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)
AuthorizeHome checks the user making the call has specified a home id on the route that matches the claims.
func AuthorizeProduct ¶
func AuthorizeProduct(productBus *productbus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)
AuthorizeProduct checks the user making the call has specified a product id on the route that matches the claims.
func AuthorizeUser ¶
func AuthorizeUser(userBus *userbus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)
AuthorizeUser checks the user making the call has specified a user id on the route that matches the claims.