network

package
v2.19.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateResponse

func CreateResponse(msg string, params ResponseParams) []byte

CreateResponse creates a generic HTTP response in JSON format.

func ExtractDomainFromURL

func ExtractDomainFromURL(hostURL *url.URL, keepSubdomain bool) string

ExtractDomainFromURL extracts the domain name (domain.tld or subdomain.domain.tld) from a URL.

func GenerateURL

func GenerateURL(host string, path string, params URLParams) (*url.URL, error)

GenerateURL creates a URL object from a host, path and optional parameters.

func ReadEndpoint

func ReadEndpoint(endpointURL *url.URL, auth *BasicAuth, checkStatus bool) ([]byte, error)

ReadEndpoint reads data from an HTTP endpoint via GET.

func WriteEndpoint

func WriteEndpoint(endpointURL *url.URL, auth *BasicAuth, checkStatus bool) ([]byte, error)

WriteEndpoint sends data to an HTTP endpoint via POST.

Types

type BasicAuth

type BasicAuth struct {
	User     string
	Password string
}

BasicAuth holds user credentials for basic HTTP authentication.

type ResponseParams

type ResponseParams map[string]interface{}

ResponseParams holds parameters of an HTTP response.

type URLParams

type URLParams map[string]string

URLParams holds Key-Value URL parameters; it is a simpler form of url.Values.

Jump to

Keyboard shortcuts

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