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) GetTimeTrace() Time
- 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)
- type Time
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"`
TimeTrace Time
// 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) GetTimeTrace ¶
GetTimeTrace set http debug mode
func (*Context) SetContentType ¶
func (ctx *Context) SetContentType(ct contentType)
SetContentType set content type on header of http request
type Time ¶
type Time struct {
Offset time.Duration `json:"offset"`
Duration time.Duration `json:"duration"`
ConnDuration time.Duration `json:"connDuration"` // connection setup(DNS lookup + Dial up) duration
DNSDuration time.Duration `json:"dnsDuration"` // dns lookup duration
ReqDuration time.Duration `json:"reqDuration"` // request "write" duration
ResDuration time.Duration `json:"resDuration"` // response "read" duration
DelayDuration time.Duration `json:"delayDuration"` // delay between response and request
}
Time ...
Click to show internal directories.
Click to hide internal directories.