Documentation ¶
Index ¶
- Constants
- Variables
- func ContentTypeValid(current string, ct contentType) bool
- type Context
- func (c *Context) Error() error
- func (c *Context) ErrorString() string
- func (c *Context) GetClient() *http.Client
- func (c *Context) GetRequest() *http.Request
- func (c *Context) GetResponse() *http.Response
- func (c *Context) HasError() bool
- func (c *Context) ResetError()
- func (ctx *Context) SetContentType(ct contentType)
- func (c *Context) SetError(err error)
- func (c *Context) TraceDo() (err error)
Constants ¶
View Source
const ( // HTML text/html HTML contentType = iota // JSON application/json JSON // XML application/xml XML // Text text/plain Text // URLEncodedForm application/x-www-form-urlencoded URLEncodedForm )
Variables ¶
View Source
var ContentTypes = map[contentType]string{ HTML: "text/html; charset=utf-8", JSON: "application/json; charset=utf-8", XML: "application/xml; charset=utf-8", Text: "text/plain; charset=utf-8", URLEncodedForm: "application/x-www-form-urlencoded; charset=utf-8", }
ContentTypes http content type map
Functions ¶
func ContentTypeValid ¶
ContentTypeValid ...
Types ¶
type Context ¶
type Context struct { Client *http.Client `json:"client,omitempty"` Request *http.Request `json:"request,omitempty"` Response *http.Response `json:"response,omitempty"` // contains filtered or unexported fields }
Context HTTP transactions
func NewWithContext ¶
func NewWithContext(ctx originContext.Context) *Context
NewWithContext creates an empty Context
func (*Context) ErrorString ¶
ErrorString get context error as string
func (*Context) GetRequest ¶
GetRequest get original http request
func (*Context) GetResponse ¶
GetResponse get original http response
func (*Context) SetContentType ¶
func (ctx *Context) SetContentType(ct contentType)
SetContentType set content type on header of http request
Click to show internal directories.
Click to hide internal directories.