http

package
v0.25.11 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GinContext

type GinContext = *gin.Context

GinContext ...

type ReqContext

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

ReqContext the request context

func Req

func Req(url string) *ReqContext

Req creates http request instance

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) Do

func (ctx *ReqContext) Do() error

Do the request

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 MustServer

func MustServer(address string) *ServerContext

MustServer ...

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) Do

func (ctx *ServerContext) Do() error

Do start the handler loop

func (*ServerContext) MustDo

func (ctx *ServerContext) MustDo()

MustDo ...

func (*ServerContext) Set added in v0.24.3

func (ctx *ServerContext) Set(server *http.Server) *ServerContext

Set options

Jump to

Keyboard shortcuts

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