mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
Merge pull request #3665 from nspcc-dev/http-code-status-ok
rpcsrv: align default error code with C# implementation
This commit is contained in:
commit
dda2cafdf8
2 changed files with 0 additions and 23 deletions
|
@ -1,8 +1,6 @@
|
|||
package rpcsrv
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/neorpc"
|
||||
)
|
||||
|
||||
|
@ -36,18 +34,3 @@ func (ab abstractBatch) RunForErrors(f func(jsonErr *neorpc.Error)) {
|
|||
a.RunForErrors(f)
|
||||
}
|
||||
}
|
||||
|
||||
func getHTTPCodeForError(respErr *neorpc.Error) int {
|
||||
var httpCode int
|
||||
switch respErr.Code {
|
||||
case neorpc.BadRequestCode:
|
||||
httpCode = http.StatusBadRequest
|
||||
case neorpc.MethodNotFoundCode:
|
||||
httpCode = http.StatusMethodNotAllowed
|
||||
case neorpc.InternalServerErrorCode:
|
||||
httpCode = http.StatusInternalServerError
|
||||
default:
|
||||
httpCode = http.StatusUnprocessableEntity
|
||||
}
|
||||
return httpCode
|
||||
}
|
||||
|
|
|
@ -3100,12 +3100,6 @@ func (s *Server) writeHTTPServerResponse(r *params.Request, w http.ResponseWrite
|
|||
if s.config.EnableCORSWorkaround {
|
||||
setCORSOriginHeaders(w.Header())
|
||||
}
|
||||
if r.In != nil {
|
||||
resp := resp.(abstract)
|
||||
if resp.Error != nil {
|
||||
w.WriteHeader(getHTTPCodeForError(resp.Error))
|
||||
}
|
||||
}
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
err := encoder.Encode(resp)
|
||||
|
|
Loading…
Reference in a new issue