httpserver

package
v0.0.0-...-ee35268 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTokenFromBearerString

func GetTokenFromBearerString(authorizationString string) (string, error)

GetTokenFromBearerString take a 'Bearer ...' string from a http.request header and returns the token without the Bearer prefix.

Returns error if auth string is empty

func HealthcheckHandler

func HealthcheckHandler(w http.ResponseWriter, r *http.Request)

HealthcheckHandler is a quick mux route useful only for responding to checks of the server being alive

func New

func New(port string, mux *http.ServeMux) *http.Server

New returns a standard server with a single mux route of "/_healthcheck" which responds '200 OK'.

If a mux is passed the above route is merged in and panics if already exists

func ValueFromReqQueryOrHeader

func ValueFromReqQueryOrHeader(key string, req *http.Request) (string, error)

ValueFromReqQueryOrHeader finds a value from either the URL query string or the header using the given key.

Useful when giving the client multiple methods to submit a value depending on their use case

Checks URL query strings first and will return that value even if both are present.

Both header and query string are checked as case insensitive.

The first value found is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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