Documentation ¶
Index ¶
- Constants
- Variables
- func FormatAndReturnJSONResponse(res http.ResponseWriter, data interface{})
- func FormatAndReturnJSONTextResponse(res http.ResponseWriter, data interface{})
- func FormatAndReturnOctetResponse(res http.ResponseWriter, data string)
- func FormatAndReturnTextResponse(res http.ResponseWriter, data string)
- func HandleFunc(pattern string, requestHandler HandlerType)
- func HandleFuncPrefix(pattern string, requestHandler HandlerType)
- func ListenAndServe(hostname string, port string)
- func ReturnBadRequestResponse(w http.ResponseWriter)
- func ReturnNotFoundResponse(w http.ResponseWriter)
- func ReturnUnauthorizedResponse(w http.ResponseWriter)
- type HandlerType
Constants ¶
const BadRequestResponse = `` /* 350-byte string literal not displayed */
BadRequestResponse represents the IMDSv2 response in the event of missing or invalid parameters in the request
UnauthorizedResponse represents the IMDSv2 response in the event of unauthorized access
Variables ¶
var ( // Routes represents the list of routes served by the http server Routes []string )
Functions ¶
func FormatAndReturnJSONResponse ¶
func FormatAndReturnJSONResponse(res http.ResponseWriter, data interface{})
FormatAndReturnJSONResponse formats the given data into JSON and returns the response
func FormatAndReturnJSONTextResponse ¶ added in v0.9.5
func FormatAndReturnJSONTextResponse(res http.ResponseWriter, data interface{})
FormatAndReturnJSONTextResponse formats the given data into JSON and returns a plaintext response
func FormatAndReturnOctetResponse ¶ added in v1.11.0
func FormatAndReturnOctetResponse(res http.ResponseWriter, data string)
FormatAndReturnOctetResponse formats the given data into an octet stream and returns the response
func FormatAndReturnTextResponse ¶
func FormatAndReturnTextResponse(res http.ResponseWriter, data string)
FormatAndReturnTextResponse formats the given data as plaintext and returns the response
func HandleFunc ¶
func HandleFunc(pattern string, requestHandler HandlerType)
HandleFunc registers the handler function for the given pattern
func HandleFuncPrefix ¶ added in v1.3.0
func HandleFuncPrefix(pattern string, requestHandler HandlerType)
HandleFuncPrefix registers the handler function for the given prefix pattern
func ListenAndServe ¶
ListenAndServe serves all patterns setup via their respective handlers
func ReturnBadRequestResponse ¶
func ReturnBadRequestResponse(w http.ResponseWriter)
ReturnBadRequestResponse returns response with 400 Bad Request
func ReturnNotFoundResponse ¶
func ReturnNotFoundResponse(w http.ResponseWriter)
ReturnNotFoundResponse returns response with 404 Not Found
func ReturnUnauthorizedResponse ¶
func ReturnUnauthorizedResponse(w http.ResponseWriter)
ReturnUnauthorizedResponse returns response with 401 Unauthorized
Types ¶
type HandlerType ¶
type HandlerType func(http.ResponseWriter, *http.Request)
HandlerType represents the function passed as an argument to HandleFunc