Documentation
¶
Overview ¶
Package fiberadapter provides Fiber middleware for MPP-protected routes.
Index ¶
- func ChargeMiddleware(m *server.Mpp, params server.ChargeParams) fiberfw.Handler
- func Credential(c *fiberfw.Ctx) *mpp.Credential
- func Receipt(c *fiberfw.Ctx) *mpp.Receipt
- func WriteChallenge(c *fiberfw.Ctx, challenge *mpp.Challenge, realm string)deprecated
- func WriteChallenges(c *fiberfw.Ctx, challenges []*mpp.Challenge, realm string)deprecated
- func WritePaymentError(c *fiberfw.Ctx, err error)deprecated
- func WritePaymentErrorWithChallenge(c *fiberfw.Ctx, err error, challenge *mpp.Challenge, realm string)deprecated
- func WritePaymentErrorWithChallenges(c *fiberfw.Ctx, err error, challenges []*mpp.Challenge, realm string)deprecated
- func WritePaymentResponse(c *fiberfw.Ctx, err error, challenges ...*mpp.Challenge)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChargeMiddleware ¶
ChargeMiddleware protects a Fiber route with the server charge flow.
func Credential ¶
func Credential(c *fiberfw.Ctx) *mpp.Credential
Credential returns the verified credential stored on the Fiber context.
func WriteChallenge
deprecated
func WriteChallenges
deprecated
added in
v0.4.0
WriteChallenges serializes a 402 response offering every challenge, one WWW-Authenticate field value per challenge in presentation order, written with realm.
Deprecated: Use WritePaymentResponse(c, nil, challenges...) instead, which writes each challenge's own Realm.
func WritePaymentError
deprecated
func WritePaymentErrorWithChallenge
deprecated
added in
v0.4.0
func WritePaymentErrorWithChallenge(c *fiberfw.Ctx, err error, challenge *mpp.Challenge, realm string)
WritePaymentErrorWithChallenge serializes an MPP error with a fresh retry challenge, written with realm.
Deprecated: Use WritePaymentResponse(c, err, challenge) instead, which writes the challenge's own Realm.
func WritePaymentErrorWithChallenges
deprecated
added in
v0.4.0
func WritePaymentErrorWithChallenges(c *fiberfw.Ctx, err error, challenges []*mpp.Challenge, realm string)
WritePaymentErrorWithChallenges serializes an MPP error with fresh retry challenges, one WWW-Authenticate field value per challenge in order, written with realm.
Deprecated: Use WritePaymentResponse(c, err, challenges...) instead, which writes each challenge's own Realm.
func WritePaymentResponse ¶ added in v0.5.1
WritePaymentResponse writes the payment response for err and challenges, each challenge as one WWW-Authenticate field value, in order, with its own Realm:
- err nil: the initial 402 Payment Required offering challenges, with a payment-required problem body. Without challenges it is a 500 internal payment error.
- err non-nil: err as RFC 9457 application/problem+json, a non-PaymentError as a 500 internal payment error. Challenges are retry offers, omitted for mpp.ErrPaymentOutcomeUnknown.
This is the Fiber equivalent of server.WritePaymentResponse. Fiber is built on fasthttp and cannot use http.ResponseWriter directly.
Types ¶
This section is empty.