handleMalformedRequest attempts to extract an ID from malformed JSON and send error
(msg json.RawMessage, parseErr error)
| 389 | |
| 390 | // handleMalformedRequest attempts to extract an ID from malformed JSON and send error |
| 391 | func (s *Server) handleMalformedRequest(msg json.RawMessage, parseErr error) { |
| 392 | // Try to extract just the ID from the malformed request |
| 393 | var partial struct { |
| 394 | ID interface{} `json:"id"` |
| 395 | } |
| 396 | if err := json.Unmarshal(msg, &partial); err == nil && partial.ID != nil { |
| 397 | s.sendError(partial.ID, ParseError, fmt.Sprintf("parse error: %v", parseErr)) |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | // sendResult sends a successful response |
| 402 | func (s *Server) sendResult(id interface{}, result interface{}) { |
no test coverage detected