Documentation ¶
Index ¶
- Constants
- func AddToContext(name contextKey, value string) func(next http.Handler) http.Handler
- func ValidateDonation(donation *DonationRequest) error
- func WriteHTTPCode(w http.ResponseWriter, code int)
- func WriteHTTPErrorCode(w http.ResponseWriter, err error, code int)
- type ChecksHandler
- type DonationHandler
- type DonationRequest
Constants ¶
const ( InvalidDonation = "invalid donation payload" ForwardingError = "error forwarding data donation" )
define error messages
const PostalCodeRegExp = "^(0[1-9]\\d{3}|[1-9]\\d{4})$"
Variables ¶
This section is empty.
Functions ¶
func AddToContext ¶
AddToContext adds a variable to the request context
func ValidateDonation ¶
func ValidateDonation(donation *DonationRequest) error
func WriteHTTPCode ¶
func WriteHTTPCode(w http.ResponseWriter, code int)
WriteHTTPCode writes given HTTP Code to the HTTP response
func WriteHTTPErrorCode ¶
func WriteHTTPErrorCode(w http.ResponseWriter, err error, code int)
WriteHTTPErrorCode writes given HTTP Code to the HTTP response and provides explanation - for errors
Types ¶
type ChecksHandler ¶
type ChecksHandler struct { }
ChecksHandler is the handler responsible for k8s checks
func NewChecksHandler ¶
func NewChecksHandler() *ChecksHandler
NewChecksHandler initializes a new handler
func (*ChecksHandler) Liveness ¶
func (e *ChecksHandler) Liveness(w http.ResponseWriter, r *http.Request)
Liveness is a check that describes if the application has started
func (*ChecksHandler) Readiness ¶
func (e *ChecksHandler) Readiness(w http.ResponseWriter, r *http.Request)
Readiness is a check if application can handle requests
func (*ChecksHandler) Routes ¶
func (e *ChecksHandler) Routes() *chi.Mux
Routes returns the routes for the ChecksHandler
type DonationHandler ¶
type DonationHandler struct { }
DonationHandler is the handler responsible for Account operations
func NewDonationHandler ¶
func NewDonationHandler() *DonationHandler
NewDonationHandler initializes a new handler
func (*DonationHandler) CreateDonation ¶
func (e *DonationHandler) CreateDonation(w http.ResponseWriter, r *http.Request)
func (*DonationHandler) Routes ¶
func (e *DonationHandler) Routes() *chi.Mux
Routes returns the routes for the DonationHandler
type DonationRequest ¶
type DonationRequest struct { PostalCode string `json:"postalCode"` RiskCase int `json:"riskCase"` }
DonationRequest represents the payload for a data donation