Documentation
¶
Index ¶
- type Context
- func (c *Context) Error(err Error)
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) GetQuery(key string) (string, bool)
- func (c *Context) GetQueryArray(key string) ([]string, bool)
- func (c *Context) HTML(str string)
- func (c *Context) JSON(json interface{})
- func (c *Context) Param(key string) string
- func (c *Context) Parse(p parser.Parser)
- func (c *Context) ParseJSON(pointer interface{})
- func (c *Context) ParseString() string
- func (c *Context) ParseXML(pointer interface{})
- func (c *Context) PostForm(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) Redirect(code int, url string)
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) String(str string)
- func (c *Context) XML(xml interface{})
- type Error
- type Goa
- type M
- type Middleware
- type Middlewares
- type Param
- type Params
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Request *http.Request
ResponseWriter http.ResponseWriter
Method string
URL *url.URL
Path string
Header http.Header
Params Params
Keys map[string]interface{}
// Response status code.
Status int
// Content-Type
Type string
// Body will be wrote in response,
// use it just like `c.Body = ...`.
// Only string and struct will be supported.
// If body is struct, will parse it as json.
// If u want to respond xml or other type data, u can `c.XML(...)` or encode it into string.
Body interface{}
// contains filtered or unexported fields
}
Context is used to receive requests and respond to requests.
func (*Context) GetQuery ¶
GetQuery returns the keyed url query value and isExit if it exists, return (value, true) otherwise it returns ("", false)
func (*Context) GetQueryArray ¶
GetQueryArray returns a slice of value for a given query key. And returns whether at least one value exists for the given key.
func (*Context) Param ¶
Param returns the value of the URL param or "". When using goa-router, it works.
func (*Context) ParseJSON ¶ added in v0.2.0
func (c *Context) ParseJSON(pointer interface{})
ParseJSON parses json-data, require a pointer.
func (*Context) ParseString ¶ added in v0.2.0
ParseString returns string-data
func (*Context) ParseXML ¶ added in v0.2.0
func (c *Context) ParseXML(pointer interface{})
ParseXML parses xml-data, require a pointer.
func (*Context) Redirect ¶
Redirect replies to the request with a redirect to url and a status code.
type Error ¶ added in v0.2.0
Error is used like c.Error(goa.Error{...}). It will create a http-error.
type Goa ¶
type Goa struct {
Context *Context
// contains filtered or unexported fields
}
Goa is the framework's instance.
func (*Goa) ComposeMiddlewares ¶ added in v0.2.0
func (app *Goa) ComposeMiddlewares()
ComposeMiddlewares composes middleware, it doesn't need to be called manually except in testing, but httptest is only available after ComposeMiddlewares is called.
type M ¶
type M map[string]interface{}
M is a convenient alias for a map[string]interface{} map. Use is as c.JSON(&goa.M{...})
type Middleware ¶
type Middleware func(*Context, func())
Middleware is based part of goa, any processing will take place here. should be used liked app.Use(middleware).