httputil

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClientTimeout specifies a time limit for requests
	// made by the Client in seconds.
	ClientTimeout = 30
	// UserAgent is the user agent header used for making
	// http requests.
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
)

Variables

This section is empty.

Functions

func GetAbsoluteURL

func GetAbsoluteURL(fullURL string, relative string) (string, error)

GetAbsoluteURL retrieves the absolute URL of a full and relative URL. Returns errors.INVALID if the urls could not be parsed.

func Is2xx

func Is2xx(status int) bool

Is2xx determines if a response status code is flagged as OK.

func Is3xx

func Is3xx(status int) bool

Is3xx determines if a response status code is a redirect.

Types

type Client

type Client interface {
	// Do creates and performs single http Request using the
	// application default client.
	//
	// Returns errors.INTERNAL if the request could not be
	// performed.
	Do(URL, method string) (*Response, error)
}

Client defines the single method interface for creating and performing requests.

func NewClient

func NewClient() Client

NewClient returns the common Client used across the application

type Response

type Response struct {
	RequestID string
	Status    int
	Body      string
	Headers   map[string]string
	Location  string
}

Response contains the client response data from the request.

Jump to

Keyboard shortcuts

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