request

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth http basic auth with username and password

func (BasicAuth) Apply

func (b BasicAuth) Apply(ctx *xcontext.Context)

Apply http basic auth with username and password

func (BasicAuth) Valid

func (b BasicAuth) Valid() bool

Valid http basic auth with username and password valid?

type BearerAuth

type BearerAuth struct {
	Data string
}

BearerAuth token

func (BearerAuth) Apply

func (b BearerAuth) Apply(ctx *xcontext.Context)

Apply bearer token

func (BearerAuth) Valid

func (b BearerAuth) Valid() bool

Valid bearer token valid?

type BodyForm added in v1.0.8

type BodyForm struct {
	Fields map[string]string
	Files  []string
}

BodyForm represents the supported form fields by file and string data.

func (BodyForm) Apply added in v1.0.8

func (fd BodyForm) Apply(ctx *xcontext.Context)

Apply Form Data

func (BodyForm) Valid added in v1.0.8

func (fd BodyForm) Valid() bool

Valid form body valid?

type BodyJSON

type BodyJSON struct {
	Data interface{}
}

BodyJSON body of type json

func (BodyJSON) Apply

func (b BodyJSON) Apply(ctx *xcontext.Context)

Apply json body

func (BodyJSON) Valid

func (b BodyJSON) Valid() bool

Valid json body valid?

type BodyString

type BodyString struct {
	Data string
}

BodyString body of type string

func (BodyString) Apply

func (b BodyString) Apply(ctx *xcontext.Context)

Apply string body

func (BodyString) Valid

func (b BodyString) Valid() bool

Valid string body valid?

type BodyURLEncodedForm added in v1.0.8

type BodyURLEncodedForm struct {
	Data interface{}
}

BodyURLEncodedForm application/x-www-form-urlencoded

func (BodyURLEncodedForm) Apply added in v1.0.8

func (b BodyURLEncodedForm) Apply(ctx *xcontext.Context)

Apply application/x-www-form-urlencoded

func (BodyURLEncodedForm) Valid added in v1.0.8

func (b BodyURLEncodedForm) Valid() bool

Valid application/x-www-form-urlencoded valid?

type BodyXML

type BodyXML struct {
	Data interface{}
}

BodyXML body of type xml

func (BodyXML) Apply

func (b BodyXML) Apply(ctx *xcontext.Context)

Apply xml body

func (BodyXML) Valid

func (b BodyXML) Valid() bool

Valid xml body valid?

type BodyYAML added in v1.0.8

type BodyYAML struct {
	Data interface{}
}

BodyYAML body of type yaml

func (BodyYAML) Apply added in v1.0.8

func (b BodyYAML) Apply(ctx *xcontext.Context)

Apply yaml body

func (BodyYAML) Valid added in v1.0.8

func (b BodyYAML) Valid() bool

Valid json body valid?

type Cookies

type Cookies struct {
	Data []*http.Cookie
	Map  map[string]string
}

Cookies http cookies

func (Cookies) Apply

func (c Cookies) Apply(ctx *xcontext.Context)

Apply http cookies

func (Cookies) Valid

func (c Cookies) Valid() bool

Valid http cookies valid?

type CustomerAuth

type CustomerAuth struct {
	Data string
}

CustomerAuth customer Authorization on header

func (CustomerAuth) Apply

func (c CustomerAuth) Apply(ctx *xcontext.Context)

Apply customer Authorization on header

func (CustomerAuth) Valid

func (c CustomerAuth) Valid() bool

Valid customer Authorization on header valid?

type FormFile

type FormFile struct {
	Name   string
	Reader io.Reader
}

FormFile represents the file form field data.

type Header struct {
	Data map[string]string
}

Header http header

func (Header) Apply

func (h Header) Apply(ctx *xcontext.Context)

Apply apply http headers

func (Header) Valid

func (h Header) Valid() bool

Valid user agent in header valid?

type Host

type Host struct {
	Data string
}

Host http host name like: https://www.google.com

func (Host) Apply

func (h Host) Apply(ctx *xcontext.Context)

Apply http host name like: https://www.google.com

func (Host) Valid

func (h Host) Valid() bool

Valid http host name like: https://www.google.com valid?

type Method

type Method struct {
	Data string
}

Method http method: GET, POST, DELETE ...

func (Method) Apply

func (m Method) Apply(ctx *xcontext.Context)

Apply http method: GET, POST, DELETE ...

func (Method) Valid

func (m Method) Valid() bool

Valid http method: GET, POST, DELETE ... valid?

type Path

type Path struct {
	Data string
}

Path http url path like: /api/v1/xx

func (Path) Apply

func (p Path) Apply(ctx *xcontext.Context)

Apply http url path like: /api/v1/xx

func (Path) Valid

func (p Path) Valid() bool

Valid http url path like: /api/v1/xx valid?

type Plugin

type Plugin interface {

	// Apply the plugin to http request
	Apply(*xcontext.Context)

	// Valid is the plugin need run?
	Valid() bool
}

Plugin parse user defined request

type Proxy

type Proxy struct {
	Servers map[string]string
	URL     string
}

Proxy http proxy url or multi services

func (Proxy) Apply

func (p Proxy) Apply(ctx *xcontext.Context)

Apply http proxy url or multi services

func (Proxy) Valid

func (p Proxy) Valid() bool

Valid http proxy url or multi services valid?

type Query

type Query struct {
	Data map[string]string
}

Query http query params like: ?a=1&b=2

func (Query) Apply

func (q Query) Apply(ctx *xcontext.Context)

Apply http query params like: ?a=1&b=2

func (Query) Valid

func (q Query) Valid() bool

Valid http url path like: /api/v1/xx valid?

type Request added in v1.0.8

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

Request an alias of context

func New added in v1.0.8

func New() *Request

New request struct

func NewWithContext added in v1.0.13

func NewWithContext(ctx originContext.Context) *Request

NewWithContext request struct

func (*Request) AddBasicAuth added in v1.0.8

func (r *Request) AddBasicAuth(username, password string) *Request

AddBasicAuth ...

func (*Request) AddBearerAuth added in v1.0.8

func (r *Request) AddBearerAuth(data string) *Request

AddBearerAuth ...

func (*Request) AddCookiesMap added in v1.0.8

func (r *Request) AddCookiesMap(data map[string]string) *Request

AddCookiesMap ...

func (*Request) AddHeader added in v1.0.8

func (r *Request) AddHeader(data map[string]string) *Request

AddHeader ...

func (*Request) AddJSON added in v1.0.8

func (r *Request) AddJSON(data interface{}) *Request

AddJSON ...

func (*Request) AddMultipartForm added in v1.0.10

func (r *Request) AddMultipartForm(fields map[string]string, files []string) *Request

AddMultipartForm ...

func (*Request) AddQuery added in v1.0.8

func (r *Request) AddQuery(data map[string]string) *Request

AddQuery ...

func (*Request) AddSortedHeader added in v1.0.9

func (r *Request) AddSortedHeader(data [][2]string) *Request

AddSortedHeader ...

func (*Request) AddTLSConfig added in v1.0.8

func (r *Request) AddTLSConfig(data *tls.Config) *Request

AddTLSConfig ...

func (*Request) AddTransform added in v1.0.8

func (r *Request) AddTransform(data *http.Transport) *Request

AddTransform ...

func (*Request) AddURLEncodedForm added in v1.0.8

func (r *Request) AddURLEncodedForm(data interface{}) *Request

AddURLEncodedForm ...

func (*Request) AddXML added in v1.0.8

func (r *Request) AddXML(data interface{}) *Request

AddXML ...

func (*Request) AddYAML added in v1.0.8

func (r *Request) AddYAML(data interface{}) *Request

AddYAML ...

func (*Request) Ctx added in v1.0.8

func (r *Request) Ctx() *xcontext.Context

Ctx get request ctx

func (*Request) DELETE added in v1.0.8

func (r *Request) DELETE(url string) *Request

DELETE use DELETE method and http url

func (*Request) Error added in v1.0.8

func (r *Request) Error() error

Error get request error

func (*Request) GET added in v1.0.8

func (r *Request) GET(url string) *Request

GET use GET method and http url

func (*Request) HEAD added in v1.0.8

func (r *Request) HEAD(url string) *Request

HEAD use HEAD method and http url

func (*Request) OPTIONS added in v1.0.8

func (r *Request) OPTIONS(url string) *Request

OPTIONS use OPTIONS method and http url

func (*Request) PATCH added in v1.0.8

func (r *Request) PATCH(url string) *Request

PATCH use PATCH method and http url

func (*Request) POST added in v1.0.8

func (r *Request) POST(url string) *Request

POST use POST method and http url

func (*Request) PUT added in v1.0.8

func (r *Request) PUT(url string) *Request

PUT use PUT method and http url

func (*Request) Send added in v1.0.8

func (r *Request) Send() *response.Sugar

Send ...

func (*Request) TRACE added in v1.0.8

func (r *Request) TRACE(url string) *Request

TRACE use TRACE method and http url

type SortedHeader added in v1.0.9

type SortedHeader struct {
	Data [][2]string
}

SortedHeader header slice, example [][2]string{{k1,v1},{k2,v2}}

func (SortedHeader) Apply added in v1.0.9

func (h SortedHeader) Apply(ctx *xcontext.Context)

Apply apply http headers

func (SortedHeader) Valid added in v1.0.9

func (h SortedHeader) Valid() bool

Valid user agent in header valid?

type TLSConfig

type TLSConfig struct {
	*tls.Config
}

TLSConfig http tls config of transport

func (TLSConfig) Apply

func (tc TLSConfig) Apply(ctx *xcontext.Context)

Apply http tls config of transport

func (TLSConfig) Valid

func (tc TLSConfig) Valid() bool

Valid http timeouts of tls, dial, keepalive or all valid?

type Timeout added in v1.0.16

type Timeout struct {
	// Data represents the total timeout including dial / request / redirect steps
	Data time.Duration
}

Timeout represents the supported timeouts

func (Timeout) Apply added in v1.0.16

func (to Timeout) Apply(ctx *xcontext.Context)

Apply http timeouts of tls, dial, keepalive or all

func (Timeout) Valid added in v1.0.16

func (to Timeout) Valid() bool

Valid http timeouts of tls, dial, keepalive or all valid?

type Transport

type Transport struct {
	*http.Transport
}

Transport http Transport

func (Transport) Apply

func (t Transport) Apply(ctx *xcontext.Context)

Apply http Transport

func (Transport) Valid

func (t Transport) Valid() bool

Valid http timeouts of tls, dial, keepalive or all valid?

type URL

type URL struct {
	Data string
}

URL http url (host+path+params)

func (URL) Apply

func (_u URL) Apply(ctx *xcontext.Context)

Apply http url (host+path+params)

func (URL) Valid

func (_u URL) Valid() bool

Valid http url path like: /api/v1/xx valid?

type UserAgent

type UserAgent struct {
	Version string
}

UserAgent user agent in header

func (UserAgent) Apply

func (ua UserAgent) Apply(ctx *xcontext.Context)

Apply user agent in header

func (UserAgent) Valid

func (ua UserAgent) Valid() bool

Valid user agent in header valid?

Jump to

Keyboard shortcuts

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