anyhttp

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResReqFastHTTP added in v0.2.0

func NewResReqFastHTTP(ctx *fasthttp.RequestCtx) (ResponseFastHTTP, *RequestFastHTTP)

func NewResReqNetHTTP added in v0.2.0

func NewResReqNetHTTP(res http.ResponseWriter, req *http.Request) (ResponseNetHTTP, *RequestNetHTTP)

func WriteSimpleJSON added in v0.2.0

func WriteSimpleJSON(w Response, status int, message string) (int, error)

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 added in v0.2.0

type ArgsFastHTTP struct{ Raw *fasthttp.Args }

func NewArgsFastHTTP added in v0.2.0

func NewArgsFastHTTP(args *fasthttp.Args) ArgsFastHTTP

func (ArgsFastHTTP) GetBytes added in v0.2.0

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

func (ArgsFastHTTP) GetBytesSlice added in v0.2.0

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

func (ArgsFastHTTP) GetString added in v0.2.0

func (a ArgsFastHTTP) GetString(key string) string

func (ArgsFastHTTP) GetStringSlice added in v0.2.0

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

func (ArgsFastHTTP) GetURLValues added in v0.2.0

func (a ArgsFastHTTP) GetURLValues() url.Values

type ArgsFastHTTPMulti added in v0.2.0

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

func NewArgsFastHTTPMulti added in v0.2.0

func NewArgsFastHTTPMulti(args []*fasthttp.Args) ArgsFastHTTPMulti

func (ArgsFastHTTPMulti) GetBytes added in v0.2.0

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

func (ArgsFastHTTPMulti) GetBytesSlice added in v0.2.0

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

func (ArgsFastHTTPMulti) GetString added in v0.2.0

func (args ArgsFastHTTPMulti) GetString(key string) string

func (ArgsFastHTTPMulti) GetStringSlice added in v0.2.0

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

func (ArgsFastHTTPMulti) GetURLValues added in v0.2.0

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 added in v0.2.0

type ArgsURLValues struct{ Raw url.Values }

func NewArgsURLValues added in v0.2.0

func NewArgsURLValues(args url.Values) ArgsURLValues

func (ArgsURLValues) GetBytes added in v0.2.0

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

func (ArgsURLValues) GetBytesSlice added in v0.2.0

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

func (ArgsURLValues) GetString added in v0.2.0

func (args ArgsURLValues) GetString(key string) string

func (ArgsURLValues) GetStringSlice added in v0.2.0

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

func (ArgsURLValues) GetURLValues added in v0.2.0

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

func (*Cookie) ToFastHTTP added in v0.2.0

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

func (*Cookie) ToNetHTTP added in v0.2.0

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 added in v0.2.0

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

func NewRequestFastHTTP added in v0.2.0

func NewRequestFastHTTP(ctx *fasthttp.RequestCtx) *RequestFastHTTP

func (RequestFastHTTP) AllArgs added in v0.2.0

func (r RequestFastHTTP) AllArgs() Args

func (RequestFastHTTP) Header added in v0.2.0

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

func (RequestFastHTTP) HeaderString added in v0.2.0

func (r RequestFastHTTP) HeaderString(s string) string

func (RequestFastHTTP) Method added in v0.2.0

func (r RequestFastHTTP) Method() []byte

func (RequestFastHTTP) MultipartForm added in v0.2.0

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

func (RequestFastHTTP) ParseForm added in v0.2.0

func (r RequestFastHTTP) ParseForm() error

func (RequestFastHTTP) PostArgs added in v0.2.0

func (r RequestFastHTTP) PostArgs() Args

func (RequestFastHTTP) PostBody added in v0.2.0

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

func (RequestFastHTTP) QueryArgs added in v0.2.0

func (r RequestFastHTTP) QueryArgs() Args

func (RequestFastHTTP) RemoteAddr added in v0.2.0

func (r RequestFastHTTP) RemoteAddr() net.Addr

func (RequestFastHTTP) RemoteAddress added in v0.2.0

func (r RequestFastHTTP) RemoteAddress() string

func (RequestFastHTTP) RequestURI added in v0.2.0

func (r RequestFastHTTP) RequestURI() []byte

func (RequestFastHTTP) RequestURIVar added in v0.2.0

func (r RequestFastHTTP) RequestURIVar(s string) string

func (RequestFastHTTP) UserAgent added in v0.2.0

func (r RequestFastHTTP) UserAgent() []byte

type RequestNetHTTP added in v0.2.0

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

func NewRequestNetHTTP added in v0.2.0

func NewRequestNetHTTP(req *http.Request) *RequestNetHTTP

func (RequestNetHTTP) AllArgs added in v0.2.0

func (r RequestNetHTTP) AllArgs() Args

func (RequestNetHTTP) Form added in v0.2.0

func (r RequestNetHTTP) Form() url.Values

func (RequestNetHTTP) Header added in v0.2.0

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

func (RequestNetHTTP) HeaderString added in v0.2.0

func (r RequestNetHTTP) HeaderString(s string) string

func (RequestNetHTTP) Headers added in v0.2.0

func (r RequestNetHTTP) Headers() http.Header

func (RequestNetHTTP) Method added in v0.2.0

func (r RequestNetHTTP) Method() []byte

func (*RequestNetHTTP) MultipartForm added in v0.2.0

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

func (*RequestNetHTTP) ParseForm added in v0.2.0

func (r *RequestNetHTTP) ParseForm() error

func (RequestNetHTTP) PostArgs added in v0.2.0

func (r RequestNetHTTP) PostArgs() Args

func (RequestNetHTTP) PostBody added in v0.2.0

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

func (RequestNetHTTP) QueryArgs added in v0.2.0

func (r RequestNetHTTP) QueryArgs() Args

func (RequestNetHTTP) RemoteAddr added in v0.2.0

func (r RequestNetHTTP) RemoteAddr() net.Addr

func (RequestNetHTTP) RemoteAddress added in v0.2.0

func (r RequestNetHTTP) RemoteAddress() string

func (RequestNetHTTP) RequestURI added in v0.2.0

func (r RequestNetHTTP) RequestURI() []byte

func (RequestNetHTTP) RequestURIVar added in v0.2.0

func (r RequestNetHTTP) RequestURIVar(s string) string

func (RequestNetHTTP) UserAgent added in v0.2.0

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 added in v0.2.0

type ResponseFastHTTP struct {
	Raw *fasthttp.RequestCtx
}

func NewResponseFastHTTP added in v0.2.0

func NewResponseFastHTTP(ctx *fasthttp.RequestCtx) ResponseFastHTTP

func (ResponseFastHTTP) GetHeader added in v0.2.0

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

func (ResponseFastHTTP) SetBodyBytes added in v0.2.0

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

func (ResponseFastHTTP) SetBodyStream added in v0.2.0

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 added in v0.2.0

func (w ResponseFastHTTP) SetContentType(ct string)

func (ResponseFastHTTP) SetCookie added in v0.2.0

func (w ResponseFastHTTP) SetCookie(cookie *Cookie)

func (ResponseFastHTTP) SetHeader added in v0.2.0

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

func (ResponseFastHTTP) SetStatusCode added in v0.2.0

func (w ResponseFastHTTP) SetStatusCode(code int)

type ResponseNetHTTP added in v0.2.0

type ResponseNetHTTP struct{ Raw http.ResponseWriter }

func NewResponseNetHTTP added in v0.2.0

func NewResponseNetHTTP(w http.ResponseWriter) ResponseNetHTTP

func (ResponseNetHTTP) GetHeader added in v0.2.0

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

func (ResponseNetHTTP) SetBodyBytes added in v0.2.0

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

func (ResponseNetHTTP) SetBodyStream added in v0.2.0

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 added in v0.2.0

func (w ResponseNetHTTP) SetContentType(ct string)

func (ResponseNetHTTP) SetCookie added in v0.2.0

func (w ResponseNetHTTP) SetCookie(cookie *Cookie)

func (ResponseNetHTTP) SetHeader added in v0.2.0

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

func (ResponseNetHTTP) SetStatusCode added in v0.2.0

func (w ResponseNetHTTP) SetStatusCode(code int)

Jump to

Keyboard shortcuts

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