util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAddress added in v0.1.1

func BuildAddress(ip, port string) (string, error)

func CloneRequest

func CloneRequest(r *http.Request, body []byte) *http.Request

cloneRequest returns a clone of the provided *http.Request. The clone is a shallow copy of the struct and its Header map.

func DoRequest

func DoRequest(method, host, body string, timeout time.Duration) (string, error)

func ExternalIP

func ExternalIP() (string, error)

func GetHostPort

func GetHostPort(addr string) (host string, port string, err error)

func Min

func Min(a, b int) int

func NewTemplate

func NewTemplate(outputTmpl string) *template.Template

func Now

func Now() time.Duration

now returns time.Duration using stdlib time

func ParseHTTPHeader

func ParseHTTPHeader(in string) ([]string, error)

func ReadBody

func ReadBody(r *http.Request, obj interface{}) (string, error)

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, message string)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

func RespondWithJSONIndent

func RespondWithJSONIndent(w http.ResponseWriter, code int, payload interface{})

func WaitSignal

func WaitSignal(stopChan chan struct{})

WaitSignal awaits for SIGINT or SIGTERM and closes the channel

Types

This section is empty.

Jump to

Keyboard shortcuts

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