server

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const BadRequestResponse = `` /* 350-byte string literal not displayed */

BadRequestResponse represents the IMDSv2 response in the event of missing or invalid parameters in the request

View Source
const UnauthorizedResponse = `` /* 352-byte string literal not displayed */

UnauthorizedResponse represents the IMDSv2 response in the event of unauthorized access

Variables

View Source
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

func ListenAndServe(hostname string, port string)

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

Jump to

Keyboard shortcuts

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