Documentation ¶
Overview ¶
Package goa implements a web framework called goa.
See https://goa-go.github.io for more information about goa.
Index ¶
- type Context
- func (c *Context) Cookie(name string) (string, error)
- func (c *Context) Error(code int, msg string)
- func (c *Context) FormFile(name string) (multipart.File, *multipart.FileHeader, 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) GetStatus() int
- func (c *Context) HTML(html string)
- func (c *Context) JSON(json interface{})
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) ParseForm(pointer interface{}) error
- func (c *Context) ParseJSON(pointer interface{}) error
- func (c *Context) ParseQuery(pointer interface{}) error
- func (c *Context) ParseString() (string, error)
- func (c *Context) ParseXML(pointer interface{}) error
- 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) SetCookie(cookie *http.Cookie)
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) Status(code int)
- 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{} // whether handled response by c.ResponseWriter Handled bool // contains filtered or unexported fields }
Context is used to receive requests and respond to requests.
func (*Context) Cookie ¶ added in v0.4.1
Cookie returns the named cookie provided in the request or ErrNoCookie if not found.
func (*Context) FormFile ¶ added in v0.4.2
FormFile returns the first file for the provided form key.
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) Next ¶ added in v0.4.0
func (c *Context) Next()
Next implements the next middleware. For example,
app.Use(func(c *goa.Context) { //do sth c.Next() //do sth })
func (*Context) Param ¶
Param returns the value of the URL param or "". When using goa-router, it works.
func (*Context) ParseForm ¶ added in v0.2.1
ParseForm can parse form-data and x-www-form-urlencoded, the latter is not available when the request method is get, require a pointer. Just like json, it also needs a "form" tag. Here is a example.
type Person struct { Name string `form:"name"` Age int `form:"age"` }
p := &Person{} c.ParseForm(p)
func (*Context) ParseQuery ¶ added in v0.2.1
ParseQuery can parse query, require a pointer. Just like json, it also needs a "query" tag. Here is a example.
type Person struct { Name string `query:"name"` Age int `query:"age"` }
p := &Person{} c.ParseQuery(p)
func (*Context) ParseString ¶ added in v0.2.0
ParseString returns string-data
func (*Context) Redirect ¶
Redirect replies to the request with a redirect to url and a status code.
func (*Context) SetCookie ¶ added in v0.4.1
SetCookie adds a Set-Cookie header to the ResponseWriter's headers.
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 {
// contains filtered or unexported fields
}
Goa is the framework's instance.
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)
Middleware is based part of goa, any processing will take place here. should be used liked app.Use(middleware).