mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 20:12:25 +00:00
Move http write functions to writers.go
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrParseError = -32700
|
||||
ErrParseErrorS = "Parse error"
|
||||
@@ -24,16 +19,3 @@ const (
|
||||
ErrContextVersion = -32010
|
||||
ErrContextVersionS = "Invalid context version"
|
||||
)
|
||||
|
||||
func WriteRouterError(w http.ResponseWriter, status int, e *RPCError) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
|
||||
data, err := json.Marshal(e)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = w.Write(data)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user