es_response

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Code1xxInformational = 1
	Code2xxSuccess       = 2
	Code3xxRedirection   = 3
	Code4xxClientErrors  = 4
	Code5xxServerErrors  = 5
)
View Source
const (
	MaximumJsonSize = 16 * 1048576 // 16MiB
)

Variables

View Source
var (
	ErrorContentIsNotAJSON = errors.New("contents are not json")
	ErrorContentIsTooLarge = errors.New("contents are too large to process")
	ErrorNoContent         = errors.New("no content")
)

Functions

This section is empty.

Types

type Body

type Body interface {
	// Length of the read content in bytes
	ContentLength() int64

	// Body bytes. Returns empty array if the body written in to the file.
	Body() []byte

	// Body in string. Returns empty string if the body written into the file.
	BodyString() string

	// Body file. Return empty string if the body loaded on the memory.
	File() string

	// True when the body written into the file.
	IsFile() bool

	// Retrieve body as file. Returns empty string & error if an error happened during write.
	AsFile() (string, error)

	// Parse body as JSON.
	AsJson() (es_json.Json, error)

	// Parse body & returns non nil json instance.
	Json() es_json.Json
}

type CodeCategory

type CodeCategory int

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy implementation of Response

func NewProxy

func NewProxy(res Response) Proxy

Create new instance of the proxy instance.

func (Proxy) Alt

func (z Proxy) Alt() Body

func (Proxy) Code

func (z Proxy) Code() int

func (Proxy) CodeCategory

func (z Proxy) CodeCategory() CodeCategory

func (Proxy) Failure

func (z Proxy) Failure() (error, bool)

func (Proxy) Header

func (z Proxy) Header(header string) string

func (Proxy) Headers

func (z Proxy) Headers() map[string]string

func (Proxy) IsSuccess

func (z Proxy) IsSuccess() bool

func (Proxy) Proto

func (z Proxy) Proto() string

func (Proxy) Success

func (z Proxy) Success() Body

func (Proxy) TransportError

func (z Proxy) TransportError() error

type Response

type Response interface {
	// Status code.
	Code() int

	// Status code category.
	CodeCategory() CodeCategory

	// Protocol
	Proto() string

	// Response headers.
	Headers() map[string]string

	// Get header value. Ignore cases.
	// Returns empty string, if no header found in the response.
	Header(header string) string

	// True if the content type is text like mime type of text/plain, application/json, etc.
	IsTextContentType() bool

	// True on the response recognized as success.
	IsSuccess() bool

	// Returns error & true when the response is an error.
	Failure() (error, bool)

	// Response body on success.
	// Returns empty body when the response is not recognized as success.
	Success() Body

	// Alternative response body. Returns empty body on success.
	Alt() Body

	// Error on IO. Returns nil if no errors during the process.
	TransportError() error
}

Jump to

Keyboard shortcuts

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