Documentation
¶
Index ¶
- type GinContext
- type ReqContext
- func (ctx *ReqContext) Body(b io.Reader) *ReqContext
- func (ctx *ReqContext) Bytes() ([]byte, error)
- func (ctx *ReqContext) Client(c *http.Client) *ReqContext
- func (ctx *ReqContext) Context(c context.Context) *ReqContext
- func (ctx *ReqContext) Delete() *ReqContext
- func (ctx *ReqContext) Do() error
- func (ctx *ReqContext) Form(params ...interface{}) *ReqContext
- func (ctx *ReqContext) Header(params ...string) *ReqContext
- func (ctx *ReqContext) Headers(header http.Header) *ReqContext
- func (ctx *ReqContext) Host(host string) *ReqContext
- func (ctx *ReqContext) JSON() (utils.JSONResult, error)
- func (ctx *ReqContext) JSONBody(data interface{}) *ReqContext
- func (ctx *ReqContext) Method(m string) *ReqContext
- func (ctx *ReqContext) MustBytes() []byte
- func (ctx *ReqContext) MustCurl() string
- func (ctx *ReqContext) MustDo()
- func (ctx *ReqContext) MustJSON() utils.JSONResult
- func (ctx *ReqContext) MustResponse() *http.Response
- func (ctx *ReqContext) MustString() string
- func (ctx *ReqContext) Post() *ReqContext
- func (ctx *ReqContext) Proxy(url string) *ReqContext
- func (ctx *ReqContext) Put() *ReqContext
- func (ctx *ReqContext) Query(params ...interface{}) *ReqContext
- func (ctx *ReqContext) Request() (*http.Request, error)
- func (ctx *ReqContext) Response() (*http.Response, error)
- func (ctx *ReqContext) String() (string, error)
- func (ctx *ReqContext) StringBody(s string) *ReqContext
- func (ctx *ReqContext) Timeout(d time.Duration) *ReqContext
- func (ctx *ReqContext) URL(url string) *ReqContext
- type ServerContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReqContext ¶
type ReqContext struct {
// contains filtered or unexported fields
}
ReqContext the request context
func (*ReqContext) Body ¶
func (ctx *ReqContext) Body(b io.Reader) *ReqContext
Body sets the request body
func (*ReqContext) Bytes ¶
func (ctx *ReqContext) Bytes() ([]byte, error)
Bytes sends request, read response body as bytes
func (*ReqContext) Client ¶
func (ctx *ReqContext) Client(c *http.Client) *ReqContext
Client sets http client
func (*ReqContext) Context ¶ added in v0.19.0
func (ctx *ReqContext) Context(c context.Context) *ReqContext
Context sets the context of the request
func (*ReqContext) Delete ¶
func (ctx *ReqContext) Delete() *ReqContext
Delete sets the request method to DELETE
func (*ReqContext) Form ¶
func (ctx *ReqContext) Form(params ...interface{}) *ReqContext
Form sets the request body as form, example Form(k, v, k, v)
func (*ReqContext) Header ¶
func (ctx *ReqContext) Header(params ...string) *ReqContext
Header appends the request header, example Header(k, v, k, v ...)
func (*ReqContext) Headers ¶ added in v0.24.2
func (ctx *ReqContext) Headers(header http.Header) *ReqContext
Headers sets the request header
func (*ReqContext) Host ¶ added in v0.17.1
func (ctx *ReqContext) Host(host string) *ReqContext
Host sets the host request header
func (*ReqContext) JSON ¶
func (ctx *ReqContext) JSON() (utils.JSONResult, error)
JSON sends request, get response and parse body as json and provide searching for json strings
func (*ReqContext) JSONBody ¶
func (ctx *ReqContext) JSONBody(data interface{}) *ReqContext
JSONBody sets request body as json
func (*ReqContext) Method ¶
func (ctx *ReqContext) Method(m string) *ReqContext
Method sets request method
func (*ReqContext) MustBytes ¶
func (ctx *ReqContext) MustBytes() []byte
MustBytes panic version of Bytes()
func (*ReqContext) MustCurl ¶ added in v0.16.2
func (ctx *ReqContext) MustCurl() string
MustCurl generates request and response details in curl style. Useful when reproduce request on other systems with minimum dependencies. For now gzip is not handled.
func (*ReqContext) MustDo ¶
func (ctx *ReqContext) MustDo()
MustDo send request, panic if request fails
func (*ReqContext) MustJSON ¶
func (ctx *ReqContext) MustJSON() utils.JSONResult
MustJSON panic version of JSON()
func (*ReqContext) MustResponse ¶
func (ctx *ReqContext) MustResponse() *http.Response
MustResponse panic version of Response
func (*ReqContext) MustString ¶
func (ctx *ReqContext) MustString() string
MustString panic version of String()
func (*ReqContext) Post ¶
func (ctx *ReqContext) Post() *ReqContext
Post sets the request method to POST
func (*ReqContext) Proxy ¶ added in v0.24.7
func (ctx *ReqContext) Proxy(url string) *ReqContext
Proxy sets the proxy for request
func (*ReqContext) Put ¶
func (ctx *ReqContext) Put() *ReqContext
Put sets the request method to PUT
func (*ReqContext) Query ¶
func (ctx *ReqContext) Query(params ...interface{}) *ReqContext
Query sets the query string of the request, example Query(k, v, k, v ...)
func (*ReqContext) Request ¶
func (ctx *ReqContext) Request() (*http.Request, error)
Request gets native request struct, useful for debugging
func (*ReqContext) Response ¶
func (ctx *ReqContext) Response() (*http.Response, error)
Response sends request, get response
func (*ReqContext) String ¶
func (ctx *ReqContext) String() (string, error)
String sends request, read response as string
func (*ReqContext) StringBody ¶
func (ctx *ReqContext) StringBody(s string) *ReqContext
StringBody sets request body as string
func (*ReqContext) Timeout ¶ added in v0.19.0
func (ctx *ReqContext) Timeout(d time.Duration) *ReqContext
Timeout sets the timeout of the request, it will inherit the Context
func (*ReqContext) URL ¶
func (ctx *ReqContext) URL(url string) *ReqContext
URL sets the url for request
type ServerContext ¶
type ServerContext struct { Engine *gin.Engine Listener net.Listener // contains filtered or unexported fields }
ServerContext ...
func Server ¶
func Server(address string) (*ServerContext, error)
Server listen to a port then create a gin server. I created this wrapper because gin doesn't give a signal to tell when the port is ready.
func (*ServerContext) Set ¶ added in v0.24.3
func (ctx *ServerContext) Set(server *http.Server) *ServerContext
Set options