Documentation ¶
Index ¶
- type Context
- type Input
- func (input *Input) Body() []byte
- func (input *Input) Cookie(key string) string
- func (input *Input) Header(key string) string
- func (input *Input) Host() string
- func (input *Input) IP() string
- func (input *Input) Is(method string) bool
- func (input *Input) IsAjax() bool
- func (input *Input) IsFormat(test string) bool
- func (input *Input) IsSecure() bool
- func (input *Input) IsUpload() bool
- func (input *Input) IsWebsocket() bool
- func (input *Input) Method() string
- func (input *Input) Param(key string) string
- func (input *Input) Path() string
- func (input *Input) Port() int
- func (input *Input) Protocol() string
- func (input *Input) Proxy() []string
- func (input *Input) Query(key string) string
- func (input *Input) Refer() string
- func (input *Input) Scheme() string
- func (input *Input) SubDomains() string
- func (input *Input) URL() string
- func (input *Input) UserAgent() string
- type Output
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { // RequestContentLength contains a count of incoming bytes. RequestContentLength int // ResponseContentLength contains a count of outgoing bytes. ResponseContentLength int Input *Input Output *Output Request *http.Request ResponseWriter http.ResponseWriter Params httprouter.Params // contains filtered or unexported fields }
Context is created on every request and models the event, or request. The webserver will populate a RequestContext with any data provided by the client from a form, URL, or recognized data type sent in the request body.
func New ¶
func New(w http.ResponseWriter, req *http.Request, params httprouter.Params) *Context
New produces a new request context event.
func (*Context) BadRequest ¶
func (c *Context) BadRequest(output interface{})
BadRequest issues a bad request
func (*Context) Dump ¶
func (c *Context) Dump(v interface{})
Dump spews the provided value to the stdout and is useful for debugging.
func (*Context) HTMLTemplate ¶
HTMLTemplate renders the HTML view specified by it's filename omitting the file extension.
func (*Context) InternalError ¶
func (c *Context) InternalError(output interface{})
InternalError issues a 500 Internal Server Errror
type Input ¶
type Input struct { Params map[string]string ContentType string Format string // html, xml, json, plain, etc... RequestBody []byte Request *http.Request }
Input represents the incoming request made from a client
func NewInput ¶
NewInput returns a new Webserver/context Input struct that provides useful behavior for working with HTTP requests.
func (*Input) Body ¶
Body returns the request body data as bytes and sets the content into the Input.RequestBody field.
func (*Input) Cookie ¶
Cookie returns the provided cookie by name. If the cookie does not exist an empty string is returned.
func (*Input) IP ¶
IP returns the IP address of the client. If this is a proxy request the first proxy IP is returned. If an error occurs the local IPv4 127.0.0.1 address is returned.
func (*Input) IsWebsocket ¶
IsWebsocket returns boolean of this request is in webSocket.
func (*Input) SubDomains ¶
SubDomains returns sub domain string. if aa.bb.domain.com, returns aa.bb .