network

package
v2.27.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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