define result as interface{}

This way we can easily reset the result after we hit an error, which
then omits the result.
This commit is contained in:
Gibheer 2021-05-03 19:43:25 +02:00
parent 9e6a6fbe28
commit 8953b10faa
1 changed files with 4 additions and 3 deletions

View File

@ -52,7 +52,7 @@ type (
Response struct {
ID string `json:"id"`
Messages map[string][]string `json:"messages,omitempty"`
Result map[string]interface{} `json:"result,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 {