web

package
v0.0.1-alpha9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package web contains the web API for the JWT blocklist service.

Index

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

func DebugLogIncomingRequest(r *http.Request)

DebugLogIncomingRequest pretty prints the HTTP request to debug logging

func HandleRequests

func HandleRequests(host string, port int)

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

func WriteSuccessResponse(r *http.Request, w http.ResponseWriter, message string, httpStatus int)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL