package module
v0.0.0-...-30c06b3 Latest Latest

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

Go to latest
Published: Apr 20, 2023 License: GPL-3.0 Imports: 6 Imported by: 3



GoDoc Go Report Card

Minimal HTTP requests for Golang.




View Source
const GET = http.MethodGet

GET whole or partial response from URL

View Source
const HEAD = http.MethodHead

HEAD is used to fetch headers only from URL


This section is empty.


func Version

func Version() string

Version can be used to display version information about this package in your application.


type SimpleRequest

type SimpleRequest struct {
	Method string   // Method to use to query the URL
	URL    *url.URL // URL we're requesting
	// contains filtered or unexported fields

SimpleRequest structure to be turned into a HTTP request proper

func Create

func Create(method string, reqURL string) (SimpleRequest, error)

Create is a mechanism to make a suitable http request header to find some information out about a web resouse.

func Default

func Default(reqURL *url.URL) SimpleRequest

Default will create a default object to make work easier for all.

func (*SimpleRequest) Accept

func (sr *SimpleRequest) Accept(accept string)

Accept allows us to control the response sent back

func (*SimpleRequest) Agent

func (sr *SimpleRequest) Agent(agent string)

Agent is used to supply a user agent name to the request useful to distinguish a spam request, or mock another client

func (*SimpleRequest) Byterange

func (sr *SimpleRequest) Byterange(limit string)

Byterange is used to enable partial download of content for a GET request

func (*SimpleRequest) Do

func (sr *SimpleRequest) Do() (SimpleResponse, error)

Do will perform the request for us from the SimpleRequest object itself.

func (*SimpleRequest) NoRedirect

func (sr *SimpleRequest) NoRedirect(redirect bool)

NoRedirect tells the client whether or not to follow redirects...

func (*SimpleRequest) Timeout

func (sr *SimpleRequest) Timeout(duration time.Duration)

Timeout sets the client timeout in seconds...

type SimpleResponse

type SimpleResponse struct {
	Data           string      // The payload from the response
	Header         http.Header // The header from the response
	PrettyResponse string      // Pretty printed response
	PrettyRequest  string      // Pretty printed request
	StatusText     string      // Status text from the response
	StatusCode     int         // Status code from the response
	Location       *url.URL    // Location pointed to bu resource

SimpleResponse to wrap useful components of a HTTP response

func (*SimpleResponse) GetHeader

func (sr *SimpleResponse) GetHeader(key string) string

GetHeader can be used to retrieve headers from the server's response

Jump to

Keyboard shortcuts

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