Documentation
¶
Overview ¶
Package ginadapter provides Gin middleware for MPP-protected routes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChargeMiddleware ¶
func ChargeMiddleware(m *server.Mpp, params server.ChargeParams) ginfw.HandlerFunc
ChargeMiddleware protects a Gin route with the server charge flow. It runs server.Mpp.ChargeRequest with the route's scope (its FullPath) unless params.MppxScope is set, writes the payment response when payment is required or rejected, and on success stores the verified Credential and Receipt on the Gin context and the request context.
func ComposeMiddleware ¶ added in v0.6.0
func ComposeMiddleware(offers ...server.Offer) ginfw.HandlerFunc
ComposeMiddleware protects a Gin route with several payment offers, like server.ComposeMiddleware: an unpaid request gets every offer, and a Credential is verified against the offer it echoes. Offers without their own Params.MppxScope bind the route's scope. ComposeMiddleware panics when server.ComposeMiddleware would: offers is empty, an Mpp is nil, realms differ, or an offer cannot be built.
func Credential ¶
func Credential(c *ginfw.Context) *mpp.Credential
Credential returns the verified credential stored on the Gin context.
Types ¶
This section is empty.