gozzle

package
v0.0.0-...-f0a3e70 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2016 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGet     string = "GET"
	MethodPost    string = "POST"
	MethodPut     string = "PUT"
	MethodPatch   string = "PATCH"
	MethodDelete  string = "DELETE"
	MethodOptions string = "OPTIONS"
	MethodHead    string = "HEAD"
)

Constants

Variables

View Source
var (
	ErrInvalidStatusCode   = errors.New("Invalid status code")
	ErrNilOriginalResponse = errors.New("Nil original response")
)

Variables

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	MaxSizeBody int `json:"max_size_body"`
}

Configuration represents a JSON-friendly gozzle configuration

type Gozzle

type Gozzle interface {
	Exec(reqSet RequestSet) ResponseSet
	MaxSizeBody() int
	SetMaxSizeBody(maxSizeBody int) Gozzle
}

Gozzle represents an object capable of executing a set of requests

func NewGozzle

func NewGozzle() Gozzle

NewGozzle creates a new Gozzle object

func NewGozzleFromConfiguration

func NewGozzleFromConfiguration(c Configuration) Gozzle

NewGozzleFromConfiguration creates a new Gozzle object based on a configuration

type Request

type Request interface {
	Name() string
	SetName(n string) Request
	Method() string
	SetMethod(m string) Request
	Path() string
	SetPath(p string) Request
	Headers() map[string]string
	SetHeaders(h map[string]string) Request
	AddHeader(k string, v string) Request
	GetHeader(k string) string
	DelHeader(k string) Request
	Query() map[string]string
	SetQuery(q map[string]string) Request
	AddQuery(k string, v string) Request
	GetQuery(k string) string
	DelQuery(k string) Request
	Body() interface{}
	SetBody(b interface{}) Request
	BodyReader() io.Reader
	SetBodyReader(reader io.Reader) Request
	BeforeHandler() func(r Request) bool
	SetBeforeHandler(f func(r Request) bool) Request
	AfterHandler() func(req Request, resp Response)
	SetAfterHandler(f func(req Request, resp Response)) Request
	FullPath() string
}

Request represents a request sendable by gozzle

func NewRequest

func NewRequest(name string, method string, path string) Request

NewRequest creates a new request

type RequestSet

type RequestSet interface {
	Names() []string
	AddRequest(r Request) RequestSet
	GetRequest(name string) Request
	DelRequest(name string) RequestSet
}

RequestSet represents a set of sendable requests

func NewRequestSet

func NewRequestSet() RequestSet

NewRequestSet creates a new request set

type Response

type Response interface {
	Errors() []error
	Status() string
	StatusCode() int
	Header() http.Header
	BodyReader() io.ReadCloser
	Body() ([]byte, error)
	Close() error
}

Response represents a response received by gozzle after sending a request

func NewResponse

func NewResponse(or *http.Response, maxSizeBody int) Response

NewResponse creates a new response based on an *http.Response

func NewResponseError

func NewResponseError(e error) Response

NewResponseError creates a new response with an error set by default

type ResponseSet

type ResponseSet interface {
	Names() []string
	AddResponse(req Request, resp Response) ResponseSet
	GetResponse(name string) Response
	DelResponse(name string) ResponseSet
	Close() map[string]error
}

ResponseSet represents a set of responses

func NewResponseSet

func NewResponseSet() ResponseSet

NewResponseSet creates a new response set

Jump to

Keyboard shortcuts

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