ngx

package module
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Post    = http.MethodPost
	Get     = http.MethodGet
	Head    = http.MethodHead
	Put     = http.MethodPut
	Delete  = http.MethodDelete
	Patch   = http.MethodPatch
	Options = http.MethodOptions
)

Variables

This section is empty.

Functions

func CloneHeader

func CloneHeader(src http.Header) http.Header

func CloneValues

func CloneValues(src url.Values) url.Values

Types

type ContentType

type ContentType string
const (
	ContentTypeJSON      ContentType = "application/json"
	ContentTypeXML       ContentType = "application/xml"
	ContentTypeURLEncode ContentType = "application/x-www-form-urlencoded"
	ContentTypeHTML      ContentType = "text/html"
	ContentTypeText      ContentType = "text/plain"
	ContentTypeMultipart ContentType = "multipart/form-data"
)

type FormFile

type FormFile interface {
	WriteTo(writer *multipart.Writer) error
}

type FormFiles

type FormFiles map[string]FormFile

func (FormFiles) Add

func (f FormFiles) Add(name string, file FormFile)

func (FormFiles) AddFileObject

func (f FormFiles) AddFileObject(name, filename string, file io.Reader)

func (FormFiles) AddFilePath

func (f FormFiles) AddFilePath(name, filename, filepath string)

func (FormFiles) Del

func (f FormFiles) Del(name string)

func (FormFiles) Has

func (f FormFiles) Has(name string) bool

type Option

type Option func(req *Request)

func WithBody

func WithBody(body io.Reader) Option

func WithClient

func WithClient(client *http.Client) Option

func WithCookies

func WithCookies(cookies []*http.Cookie) Option

func WithForm

func WithForm(form url.Values) Option

func WithHeader

func WithHeader(header http.Header) Option

func WithQuery

func WithQuery(query url.Values) Option

type Request

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

func NewRequest

func NewRequest(method, target string, opts ...Option) *Request

func (*Request) AddCookie

func (r *Request) AddCookie(cookie *http.Cookie)

func (*Request) Do

func (r *Request) Do(ctx context.Context) (*http.Response, error)

func (*Request) FileForm

func (r *Request) FileForm() FormFiles

func (*Request) Form

func (r *Request) Form() url.Values

func (*Request) Header

func (r *Request) Header() http.Header

func (*Request) Query

func (r *Request) Query() url.Values

func (*Request) SetBody

func (r *Request) SetBody(body io.Reader)

func (*Request) SetContentType

func (r *Request) SetContentType(contentType ContentType)

func (*Request) SetCookies

func (r *Request) SetCookies(cookies []*http.Cookie)

func (*Request) SetFileForm

func (r *Request) SetFileForm(files FormFiles)

func (*Request) SetForm

func (r *Request) SetForm(form url.Values)

func (*Request) SetHeader

func (r *Request) SetHeader(header http.Header)

func (*Request) SetQuery

func (r *Request) SetQuery(query url.Values)

func (*Request) TrimURLQuery

func (r *Request) TrimURLQuery()

Jump to

Keyboard shortcuts

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