Documentation ¶
Overview ¶
Package mid provides app level middleware support.
Index ¶
- Variables
- func GetClaims(ctx context.Context) auth.Claims
- func GetHome(ctx context.Context) (homebus.Home, error)
- func GetProduct(ctx context.Context) (productbus.Product, error)
- func GetTran(ctx context.Context) (transaction.CommitRollbacker, error)
- func GetUser(ctx context.Context) (userbus.User, error)
- func GetUserID(ctx context.Context) (uuid.UUID, error)
- type Encoder
- func Authenticate(ctx context.Context, log *logger.Logger, client *authclient.Client, ...) (Encoder, error)
- func Authorize(ctx context.Context, log *logger.Logger, client *authclient.Client, ...) (Encoder, error)
- func AuthorizeHome(ctx context.Context, log *logger.Logger, client *authclient.Client, ...) (Encoder, error)
- func AuthorizeProduct(ctx context.Context, log *logger.Logger, client *authclient.Client, ...) (Encoder, error)
- func AuthorizeUser(ctx context.Context, log *logger.Logger, client *authclient.Client, ...) (Encoder, error)
- func Basic(ctx context.Context, ath *auth.Auth, userBus *userbus.Business, ...) (Encoder, error)
- func Bearer(ctx context.Context, ath *auth.Auth, authorization string, next HandlerFunc) (Encoder, error)
- func BeginCommitRollback(ctx context.Context, log *logger.Logger, bgn transaction.Beginner, ...) (Encoder, error)
- func Errors(ctx context.Context, log *logger.Logger, next HandlerFunc) (Encoder, error)
- func Logger(ctx context.Context, log *logger.Logger, path string, rawQuery string, ...) (Encoder, error)
- func Metrics(ctx context.Context, next HandlerFunc) (Encoder, error)
- func Panics(ctx context.Context, next HandlerFunc) (resp Encoder, err error)
- type HandlerFunc
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 GetProduct ¶
func GetProduct(ctx context.Context) (productbus.Product, error)
GetProduct returns the product from the context.
func GetTran ¶
func GetTran(ctx context.Context) (transaction.CommitRollbacker, error)
GetTran retrieves the value that can manage a transaction.
Types ¶
type Encoder ¶
Encoder defines behavior that can encode a data model and provide the content type for that encoding.
func Authenticate ¶
func Authenticate(ctx context.Context, log *logger.Logger, client *authclient.Client, authorization string, next HandlerFunc) (Encoder, error)
Authenticate validates authentication via the auth service.
func Authorize ¶
func Authorize(ctx context.Context, log *logger.Logger, client *authclient.Client, rule string, next HandlerFunc) (Encoder, error)
Authorize validates authorization via the auth service.
func AuthorizeHome ¶
func AuthorizeHome(ctx context.Context, log *logger.Logger, client *authclient.Client, homeBus *homebus.Business, id string, next HandlerFunc) (Encoder, error)
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(ctx context.Context, log *logger.Logger, client *authclient.Client, productBus *productbus.Business, id string, next HandlerFunc) (Encoder, error)
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(ctx context.Context, log *logger.Logger, client *authclient.Client, userBus *userbus.Business, rule string, id string, next HandlerFunc) (Encoder, error)
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 Basic ¶
func Basic(ctx context.Context, ath *auth.Auth, userBus *userbus.Business, authorization string, next HandlerFunc) (Encoder, error)
Basic processes basic authentication logic.
func Bearer ¶
func Bearer(ctx context.Context, ath *auth.Auth, authorization string, next HandlerFunc) (Encoder, error)
Bearer processes JWT authentication logic.
func BeginCommitRollback ¶
func BeginCommitRollback(ctx context.Context, log *logger.Logger, bgn transaction.Beginner, next HandlerFunc) (Encoder, error)
BeginCommitRollback starts a transaction for the domain call.
func Logger ¶
func Logger(ctx context.Context, log *logger.Logger, path string, rawQuery string, method string, remoteAddr string, next HandlerFunc) (Encoder, error)
Logger writes information about the request to the logs.