anyhttp

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResReqNetHttp

func NewResReqNetHttp(res http.ResponseWriter, req *http.Request) (ResponseNetHttp, *RequestNetHttp)

func WriteSimpleJson

func WriteSimpleJson(w Response, status int, message string)

Types

type Addr

type Addr struct {
	Protocol string
	Address  string
}

func (Addr) Network

func (addr Addr) Network() string

func (Addr) String

func (addr Addr) String() string

type Args

type Args interface {
	GetBytes(key string) []byte
	GetBytesSlice(key string) [][]byte
	GetString(key string) string
	GetStringSlice(key string) []string
	GetURLValues() url.Values
}

type ArgsFastHttp

type ArgsFastHttp struct{ Raw *fasthttp.Args }

func NewArgsFastHttp

func NewArgsFastHttp(args *fasthttp.Args) ArgsFastHttp

func (ArgsFastHttp) GetBytes

func (a ArgsFastHttp) GetBytes(key string) []byte

func (ArgsFastHttp) GetBytesSlice

func (a ArgsFastHttp) GetBytesSlice(key string) [][]byte

func (ArgsFastHttp) GetString

func (a ArgsFastHttp) GetString(key string) string

func (ArgsFastHttp) GetStringSlice

func (a ArgsFastHttp) GetStringSlice(key string) []string

func (ArgsFastHttp) GetURLValues

func (a ArgsFastHttp) GetURLValues() url.Values

type ArgsFastHttpMulti

type ArgsFastHttpMulti struct {
	Raw []*fasthttp.Args
}

func NewArgsFastHttpMulti

func NewArgsFastHttpMulti(args []*fasthttp.Args) ArgsFastHttpMulti

func (ArgsFastHttpMulti) GetBytes

func (args ArgsFastHttpMulti) GetBytes(key string) []byte

func (ArgsFastHttpMulti) GetBytesSlice

func (args ArgsFastHttpMulti) GetBytesSlice(key string) [][]byte

func (ArgsFastHttpMulti) GetString

func (args ArgsFastHttpMulti) GetString(key string) string

func (ArgsFastHttpMulti) GetStringSlice

func (args ArgsFastHttpMulti) GetStringSlice(key string) []string

func (ArgsFastHttpMulti) GetURLValues

func (args ArgsFastHttpMulti) GetURLValues() url.Values

type ArgsMapStringString

type ArgsMapStringString struct{ Raw MapStringString }

func NewArgsMapStringString

func NewArgsMapStringString(args MapStringString) ArgsMapStringString

func (ArgsMapStringString) GetBytes

func (args ArgsMapStringString) GetBytes(key string) []byte

func (ArgsMapStringString) GetBytesSlice

func (args ArgsMapStringString) GetBytesSlice(key string) [][]byte

func (ArgsMapStringString) GetString

func (args ArgsMapStringString) GetString(key string) string

func (ArgsMapStringString) GetStringSlice

func (args ArgsMapStringString) GetStringSlice(key string) []string

type ArgsUrlValues

type ArgsUrlValues struct{ Raw url.Values }

func NewArgsUrlValues

func NewArgsUrlValues(args url.Values) ArgsUrlValues

func (ArgsUrlValues) GetBytes

func (args ArgsUrlValues) GetBytes(key string) []byte

func (ArgsUrlValues) GetBytesSlice

func (args ArgsUrlValues) GetBytesSlice(key string) [][]byte

func (ArgsUrlValues) GetString

func (args ArgsUrlValues) GetString(key string) string

func (ArgsUrlValues) GetStringSlice

func (args ArgsUrlValues) GetStringSlice(key string) []string

func (ArgsUrlValues) GetURLValues

func (args ArgsUrlValues) GetURLValues() url.Values
type Cookie struct {
	Name  string
	Value string
}

func (*Cookie) ToFastHttp

func (c *Cookie) ToFastHttp() *fasthttp.Cookie

func (*Cookie) ToNetHttp

func (c *Cookie) ToNetHttp() *http.Cookie

type MapStringString

type MapStringString map[string]string

func (MapStringString) Get

func (m MapStringString) Get(key string) string

func (MapStringString) GetSlice

func (m MapStringString) GetSlice(key string) []string

type Request

type Request interface {
	Header(s string) []byte
	HeaderString(s string) string
	RemoteAddr() net.Addr
	RemoteAddress() string
	UserAgent() []byte
	Method() []byte
	ParseForm() error
	AllArgs() Args
	QueryArgs() Args
	PostArgs() Args
	MultipartForm() (*multipart.Form, error)
	RequestURI() []byte
	RequestURIVar(s string) string
	PostBody() ([]byte, error)
}

type RequestFastHttp

type RequestFastHttp struct {
	Raw *fasthttp.RequestCtx
	// contains filtered or unexported fields
}

func NewRequestFastHttp

func NewRequestFastHttp(ctx *fasthttp.RequestCtx) *RequestFastHttp

func (RequestFastHttp) AllArgs

func (r RequestFastHttp) AllArgs() Args

func (RequestFastHttp) Header

func (r RequestFastHttp) Header(s string) []byte

func (RequestFastHttp) HeaderString

func (r RequestFastHttp) HeaderString(s string) string

func (RequestFastHttp) Method

func (r RequestFastHttp) Method() []byte

func (RequestFastHttp) MultipartForm

func (r RequestFastHttp) MultipartForm() (*multipart.Form, error)

func (RequestFastHttp) ParseForm

func (r RequestFastHttp) ParseForm() error

func (RequestFastHttp) PostArgs

func (r RequestFastHttp) PostArgs() Args

func (RequestFastHttp) PostBody

func (r RequestFastHttp) PostBody() ([]byte, error)

func (RequestFastHttp) QueryArgs

func (r RequestFastHttp) QueryArgs() Args

func (RequestFastHttp) RemoteAddr

func (r RequestFastHttp) RemoteAddr() net.Addr

func (RequestFastHttp) RemoteAddress

func (r RequestFastHttp) RemoteAddress() string

func (RequestFastHttp) RequestURI

func (r RequestFastHttp) RequestURI() []byte

func (RequestFastHttp) RequestURIVar

func (r RequestFastHttp) RequestURIVar(s string) string

func (RequestFastHttp) UserAgent

func (r RequestFastHttp) UserAgent() []byte

type RequestNetHttp

type RequestNetHttp struct {
	Raw *http.Request
	// contains filtered or unexported fields
}

func NewRequestNetHttp

func NewRequestNetHttp(req *http.Request) *RequestNetHttp

func (RequestNetHttp) AllArgs

func (r RequestNetHttp) AllArgs() Args

func (RequestNetHttp) Form

func (r RequestNetHttp) Form() url.Values

func (RequestNetHttp) Header

func (r RequestNetHttp) Header(s string) []byte

func (RequestNetHttp) HeaderString

func (r RequestNetHttp) HeaderString(s string) string

func (RequestNetHttp) Headers

func (r RequestNetHttp) Headers() http.Header

func (RequestNetHttp) Method

func (r RequestNetHttp) Method() []byte

func (*RequestNetHttp) MultipartForm

func (r *RequestNetHttp) MultipartForm() (*multipart.Form, error)

func (*RequestNetHttp) ParseForm

func (r *RequestNetHttp) ParseForm() error

func (RequestNetHttp) PostArgs

func (r RequestNetHttp) PostArgs() Args

func (RequestNetHttp) PostBody

func (r RequestNetHttp) PostBody() ([]byte, error)

func (RequestNetHttp) QueryArgs

func (r RequestNetHttp) QueryArgs() Args

func (RequestNetHttp) RemoteAddr

func (r RequestNetHttp) RemoteAddr() net.Addr

func (RequestNetHttp) RemoteAddress

func (r RequestNetHttp) RemoteAddress() string

func (RequestNetHttp) RequestURI

func (r RequestNetHttp) RequestURI() []byte

func (RequestNetHttp) RequestURIVar

func (r RequestNetHttp) RequestURIVar(s string) string

func (RequestNetHttp) UserAgent

func (r RequestNetHttp) UserAgent() []byte

type Response

type Response interface {
	SetStatusCode(int)
	SetContentType(string)
	SetCookie(cookie *Cookie)
	GetHeader(key string) []byte
	SetHeader(key, val string)
	SetBodyBytes([]byte) (int, error)
	SetBodyStream(bodyStream io.Reader, bodySize int) error
}

type ResponseFastHttp

type ResponseFastHttp struct {
	Raw *fasthttp.RequestCtx
}

func NewResponseFastHttp

func NewResponseFastHttp(ctx *fasthttp.RequestCtx) ResponseFastHttp

func (ResponseFastHttp) GetHeader

func (w ResponseFastHttp) GetHeader(k string) []byte

func (ResponseFastHttp) SetBodyBytes

func (w ResponseFastHttp) SetBodyBytes(body []byte) (int, error)

func (ResponseFastHttp) SetBodyStream

func (w ResponseFastHttp) SetBodyStream(bodyStream io.Reader, bodySize int) error

SetBodyStream takes an `io.Reader` and an optional `bodySize`. If bodySize is >= 0, then bodySize bytes must be provided by bodyStream before returning io.EOF. If bodySize < 0, then bodyStream is read until io.EOF.

func (ResponseFastHttp) SetContentType

func (w ResponseFastHttp) SetContentType(ct string)

func (ResponseFastHttp) SetCookie

func (w ResponseFastHttp) SetCookie(cookie *Cookie)

func (ResponseFastHttp) SetHeader

func (w ResponseFastHttp) SetHeader(k, v string)

func (ResponseFastHttp) SetStatusCode

func (w ResponseFastHttp) SetStatusCode(code int)

type ResponseNetHttp

type ResponseNetHttp struct{ Raw http.ResponseWriter }

func NewResponseNetHttp

func NewResponseNetHttp(w http.ResponseWriter) ResponseNetHttp

func (ResponseNetHttp) GetHeader

func (w ResponseNetHttp) GetHeader(k string) []byte

func (ResponseNetHttp) SetBodyBytes

func (w ResponseNetHttp) SetBodyBytes(body []byte) (int, error)

func (ResponseNetHttp) SetBodyStream

func (w ResponseNetHttp) SetBodyStream(bodyStream io.Reader, bodySize int) error

SetBodyStream takes an `io.Reader`. `bodySize` is accepted but ignored to fulfill the `Response` interface requirement.

func (ResponseNetHttp) SetContentType

func (w ResponseNetHttp) SetContentType(ct string)

func (ResponseNetHttp) SetCookie

func (w ResponseNetHttp) SetCookie(cookie *Cookie)

func (ResponseNetHttp) SetHeader

func (w ResponseNetHttp) SetHeader(k, v string)

func (ResponseNetHttp) SetStatusCode

func (w ResponseNetHttp) SetStatusCode(code int)

Jump to

Keyboard shortcuts

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