request

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package request provides a request object for accessing websites.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	URL string
	// contains filtered or unexported fields
}

Request is a wrapper around a url which makes it easy to access the data it points to.

func New

func New(url string) *Request

New creates a new request and initialises it with the provided url.

func NewWithContext

func NewWithContext(ctx context.Context, url string) *Request

NewWithContext creates a new request with the given context. Note that nil is a valid context.

func (*Request) Close

func (req *Request) Close()

Close performs cleanup for the Request. This is a no-op if the Request doesn't need cleanup

func (*Request) Context

func (req *Request) Context() context.Context

Context returns the context of the request.

func (*Request) Document

func (req *Request) Document() (*goquery.Document, error)

Document returns a goquery.Document for the Request.Response The Document is internally cached.

func (*Request) Request

func (req *Request) Request() *http.Request

Request creates an http.Request (GET) for the url and returns it. The request is internally cached so calling this method multiple times will return the same http.Request.

func (*Request) Reset

func (req *Request) Reset()

Reset closes the request and removes all cached data.

func (*Request) Response

func (req *Request) Response() (*http.Response, error)

Response performs the Request.Request and returns the response/error. The Response is internally cached and will be cleaned up by Request.Close.

func (*Request) Text

func (req *Request) Text() (string, error)

Text retrieves the text response. It reads the text from the Request.Response body. The text is internally cached

Jump to

Keyboard shortcuts

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