utils

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidContentType is returned by ParseRequest if it can't unmarshal it into the passed struct
	ErrInvalidContentType = errors.New("Invalid request content type")
)

Functions

func GetHTTPHost

func GetHTTPHost(r *http.Request) string

GetHTTPHost returns the currenthost in the request

func GetHTTPUrl

func GetHTTPUrl(r *http.Request) string

GetHTTPUrl returns the url in the request

func JSONResponse

func JSONResponse(w http.ResponseWriter, status int, data interface{})

JSONResponse writes JSON to an http.ResponseWriter with the corresponding status code

func ParseRequest

func ParseRequest(r *http.Request, data interface{}) error

ParseRequest takes the input body from the passed request and tries to unmarshal it into data

func RemoteAddr

func RemoteAddr(r *http.Request) string

RemoteAddr extracts the remote address of the request, taking into account proxy headers.

func RemoteIP

func RemoteIP(r *http.Request) string

RemoteIP extracts the remote IP of the request, taking into account proxy headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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