netutil

package
v1.0.44 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHostAndIP added in v1.0.40

func GetHostAndIP(bindStr string, portStr string) (host string, port int)

provide default values for host and port

func GetLocalHostByIPType added in v1.0.40

func GetLocalHostByIPType(ipType string) ([]string, error)

get the local area network IP address by ipType

func GetURLToOpen added in v1.0.41

func GetURLToOpen(host string, port int) (primary string, extra []string)

get URL based on host and port

func HandleJSON added in v1.0.37

func HandleJSON(w http.ResponseWriter, r *http.Request, h func(ctx context.Context, r *http.Request) (interface{}, error))

func IsTCPAddrServing

func IsTCPAddrServing(url string, timeout time.Duration) (bool, error)

func ParamErrorf added in v1.0.37

func ParamErrorf(format string, args ...interface{}) error

func PrintUrls added in v1.0.41

func PrintUrls(url string, extra ...string)

func ServePort

func ServePort(host string, port int, autoIncrPort bool, watchTimeout time.Duration, watch func(port int), doWithPort func(port int) error) error

suggested watch timeout: 500ms

func ServePortHTTP added in v1.0.37

func ServePortHTTP(server *http.ServeMux, host string, port int, autoIncrPort bool, watchTimeout time.Duration, watch func(port int)) error

func SetCORSHeaders added in v1.0.37

func SetCORSHeaders(w http.ResponseWriter)

allow request from arbitrary host

Types

type HttpStatusErr added in v1.0.37

type HttpStatusErr interface {
	error
	HttpStatusCode() int
}

Jump to

Keyboard shortcuts

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