(name string, actionCall actionHandler)
| 126 | type actionHandler func(Request) Response |
| 127 | |
| 128 | func (h *Handler) handle(name string, actionCall actionHandler) { |
| 129 | h.HandleFunc(name, func(w http.ResponseWriter, r *http.Request) { |
| 130 | var ( |
| 131 | req Request |
| 132 | d = json.NewDecoder(r.Body) |
| 133 | ) |
| 134 | d.UseNumber() |
| 135 | if err := d.Decode(&req); err != nil { |
| 136 | http.Error(w, err.Error(), http.StatusBadRequest) |
| 137 | } |
| 138 | |
| 139 | res := actionCall(req) |
| 140 | |
| 141 | sdk.EncodeResponse(w, res, res.Err != "") |
| 142 | }) |
| 143 | } |