Exemplo n.º 1
0
func runGoka() {
	g := goka.New()
	g.Get("/welcome", func(c *goka.Context) error {
		return c.JSON(http.StatusOK, `[{"name": "Chris McCord"}, {"name": "Matt Sears"}, {"name": "David Stump"}, {"name": "Ricardo Thompson"}]`)
	})
	g.Run(":8080") // listen and serve on 0.0.0.0:8080
}
Exemplo n.º 2
0
func loadGoka(num int) *goka.Goka {
	g := goka.New()
	for i := 0; i < num; i++ {
		g.Get(fmt.Sprintf("/welcome/%d", i), func(c *goka.Context) error {
			return c.JSON(http.StatusOK, `[{"name": "Chris McCord"}, {"name": "Matt Sears"}, {"name": "David Stump"}, {"name": "Ricardo Thompson"}]`)
		})
	}
	return g
}
Exemplo n.º 3
0
func main() {
	g := goka.New()
	g.SetDebug(true)

	g.Get("/hi", func(c *goka.Context) error {
		type User struct {
			ID   int    `json:"id"`
			Name string `json:"name"`
		}
		response := make(map[string]interface{})
		response["user"] = &User{ID: 1, Name: "goka"}
		return c.JSON(200, response)
	})

	g.Run(":8080")
}