Browse Source

define result as interface{}

This way we can easily reset the result after we hit an error, which
then omits the result.
master
Gibheer 1 year ago
parent
commit
8953b10faa
  1. 7
      server.go

7
server.go

@ -50,9 +50,9 @@ type (
// Response can have messages and/or a result to return the to client.
Response struct {
ID string `json:"id"`
Messages map[string][]string `json:"messages,omitempty"`
Result map[string]interface{} `json:"result,omitempty"`
ID string `json:"id"`
Messages map[string][]string `json:"messages,omitempty"`
Result interface{} `json:"result,omitempty"`
}
ident []byte
@ -134,6 +134,7 @@ func (s *Server) Handle(w http.ResponseWriter, r *http.Request) {
}
c.Logf(LevelInfo, "method '%s' called with '%s'", req.Method, req.Params)
if err := handler(c, req, res); err != nil {
c.w.WriteHeader(http.StatusInternalServerError)
c.Logf(LevelError, "method '%s' returned an error: %s", req.Method, err)
}
if err := tx.Commit(); err != nil {

Loading…
Cancel
Save