Пример #1
0
func greeting(w http.ResponseWriter, r *http.Request) {
	params := webapi.Params(r)
	name := params["name"].(string)
	jsonapi.SetHeader(w)
	p, _ := json.Marshal(map[string]string{"result": "hello, " + name + "!"})
	w.Write(p)
}
Пример #2
0
func add(w http.ResponseWriter, r *http.Request) {
	params := webapi.Params(r)["json"].(*struct{ X, Y int })
	jsonapi.SetHeader(w)
	p, _ := json.Marshal(map[string]int{"result": params.X + params.Y})
	w.Write(p)
}