Documentation ¶
Overview ¶
Package web contains the web API for the JWT blocklist service.
Index ¶
- Variables
- func DebugLogIncomingRequest(r *http.Request)
- func HandleRequests(host string, port int)
- func WriteCorsPreflightResponse(r *http.Request, w http.ResponseWriter)
- func WriteErrorResponse(r *http.Request, w http.ResponseWriter, errorMessage string, httpStatus int)
- func WriteSuccessResponse(r *http.Request, w http.ResponseWriter, message string, httpStatus int)
- type StandardResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrHttpMethodOnlyGet = errors.New("invalid HTTP method. Only GET is allowed") ErrHttpMethodOnlyPost = errors.New("invalid HTTP method. Only POST is allowed") ErrMissingTokenHeader = errors.New("missing HTTP header with token") ErrMissingHashHeader = errors.New("missing HTTP header with hash") ErrMissingInvalidToken = errors.New("missing or invalid token value in request") ErrMissingInvalidHash = errors.New("missing or invalid hash value in request") ErrMalformedBearerTokenFormat = errors.New("malformed bearer token format") )
General error messages returned by the web service.
Functions ¶
func DebugLogIncomingRequest ¶
DebugLogIncomingRequest pretty prints the HTTP request to debug logging
func HandleRequests ¶
HandleRequests starts the HTTP service and routes requests to individual handler functions.
func WriteCorsPreflightResponse ¶
func WriteCorsPreflightResponse(r *http.Request, w http.ResponseWriter)
Write a CORS preflight response depending on the Origin header.
func WriteErrorResponse ¶
func WriteErrorResponse(r *http.Request, w http.ResponseWriter, errorMessage string, httpStatus int)
WriteErrorResponse writes a HTTP error response with a StandardResponse JSON body.
func WriteSuccessResponse ¶
WriteSuccessResponse writes a HTTP success response with a StandardResponse JSON body.
Types ¶
type StandardResponse ¶
type StandardResponse struct { Message string `json:"message"` // the response message. IsError bool `json:"error"` // whether the request resulted in an error. }
A StandardResponse has the expected fields in a API response body.
Click to show internal directories.
Click to hide internal directories.