Coco is an http web framework for golang.
go get -u github.com/olivetree123/coco
import (
"github.com/olivetree123/coco"
)
func HelloHandler(c *coco.Coco) coco.Result {
return coco.APIResponse("Hello Coco !")
}
func main() {
c := coco.NewCoco()
c.AddRouter("GET", "/", HelloHandler)
c.Run()
}
// GET, /api?name=123
params := c.Request.URL.Query()
params.Get("name")
// GET, param in url, /api/:name
name := c.Params.ByName("name")
// POST JSON
var param DBCreateParam
decoder := json.NewDecoder(c.Request.Body)
err := decoder.Decode(¶m)