diff --git a/pkg/rpc/request.go b/pkg/rpc/request.go index af8daf6c0..5a3c21b9a 100644 --- a/pkg/rpc/request.go +++ b/pkg/rpc/request.go @@ -17,11 +17,10 @@ type ( // Request represents a standard JSON-RPC 2.0 // request: http://www.jsonrpc.org/specification#request_object. Request struct { - JSONRPC string `json:"jsonrpc"` - Method string `json:"method"` - RawParams json.RawMessage `json:"params,omitempty"` - RawID json.RawMessage `json:"id,omitempty"` - enableCORSWorkaround bool + JSONRPC string `json:"jsonrpc"` + Method string `json:"method"` + RawParams json.RawMessage `json:"params,omitempty"` + RawID json.RawMessage `json:"id,omitempty"` } // Response represents a standard JSON-RPC 2.0 @@ -35,10 +34,9 @@ type ( ) // NewRequest creates a new Request struct. -func NewRequest(corsWorkaround bool) *Request { +func NewRequest() *Request { return &Request{ - JSONRPC: jsonRPCVersion, - enableCORSWorkaround: corsWorkaround, + JSONRPC: jsonRPCVersion, } } @@ -114,7 +112,7 @@ func (s *Server) WriteResponse(r *Request, w http.ResponseWriter, result interfa func (s *Server) writeServerResponse(r *Request, w http.ResponseWriter, response Response) { w.Header().Set("Content-Type", "application/json; charset=utf-8") - if r.enableCORSWorkaround { + if s.config.EnableCORSWorkaround { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With") } diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go index 79af22f8d..83c46e52d 100644 --- a/pkg/rpc/server.go +++ b/pkg/rpc/server.go @@ -70,7 +70,7 @@ func (s *Server) Shutdown() error { } func (s *Server) requestHandler(w http.ResponseWriter, httpRequest *http.Request) { - req := NewRequest(s.config.EnableCORSWorkaround) + req := NewRequest() if httpRequest.Method != "POST" { s.WriteErrorResponse(