Created
设置HTTP请求的响应码为201,并设置响应体,等价于调用c.StatusCode = 201; c.Body = x;
Example
// curl -XPOST 'http://127.0.0.1:3000/' -v
package main
import (
"github.com/vicanso/elton"
"github.com/vicanso/elton/middleware"
)
func main() {
e := elton.New()
e.Use(middleware.NewDefaultResponder())
e.POST("/", func(c *elton.Context) (err error) {
c.Created(map[string]string{
"account": "tree.xie",
})
return
})
err := e.ListenAndServe(":3000")
if err != nil {
panic(err)
}
}