http

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: BSD-3-Clause Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const OptionResponseTypeAuto = "auto"
View Source
const OptionResponseTypeByte = "byte"
View Source
const OptionResponseTypeJson = "json"
View Source
const OptionResponseTypeResponse = "response"
View Source
const OptionResponseTypeText = "text"
View Source
const OptionTypeJson = "application/json"
View Source
const OptionTypeMultipart = "multipart/form-data"
View Source
const OptionTypeText = "text/plain"
View Source
const OptionTypeUrlencode = "application/x-www-form-urlencoded"
View Source
const OptionTypeXml = "text/xml"

Variables

This section is empty.

Functions

func GetClient

func GetClient() *xhttp.Client

func GetInputData

func GetInputData(r *http.Request, httpBodySize int64) interface{}

func NewClient

func NewClient() *xhttp.Client

func NewClientWithProxy

func NewClientWithProxy(proxy *url.URL) *xhttp.Client

func Send

func Send(options *Options) (interface{}, error)

func SendWithClient

func SendWithClient(client *xhttp.Client, options *Options) (interface{}, error)

Types

type Error

type Error struct {
	StatusCode int               `json:"statusCode"`
	Status     string            `json:"status"`
	Headers    map[string]string `json:"headers"`
	Body       string            `json:"body"`
}

func (*Error) Error

func (E *Error) Error() string

type HTTPRequest

type HTTPRequest interface {
	SetURL(baseURL string, query map[string]string) HTTPRequest
	SetHeaders(headers map[string]string) HTTPRequest
	SetBody(body []byte) HTTPRequest
	SetUrlencodeBody(body map[string]string) HTTPRequest
	SetMultipartBody(cb func(w *multipart.Writer)) HTTPRequest
	SetJSONBody(interface{}) HTTPRequest
	SetTimeout(timeout time.Duration) HTTPRequest
	SetOutput(out io.Writer) HTTPRequest
	Send() (HTTPResponse, error)
	SendWithClient(client *xhttp.Client) (HTTPResponse, error)
	SetClient(client *xhttp.Client) HTTPRequest
}

func NewHTTPRequest

func NewHTTPRequest(method string) HTTPRequest

type HTTPResponse

type HTTPResponse interface {
	Code() int
	Headers() map[string]string
	Body() []byte
	PraseBody() (interface{}, error)
}

type Options

type Options struct {
	Url             string
	Method          string
	Type            string
	ResponseType    string
	Data            interface{}
	Headers         map[string]string
	RedirectCount   int
	Timeout         time.Duration
	ResponseCharset string
}

Jump to

Keyboard shortcuts

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