How can I customize HTTP 400 responses for parse errors?
I've written a REST API service that requires that all responses be JSON. However, when the Go HTTP request parser encounters an error, it returns 400 as a plain text response without ever calling my handlers. Example: > curl -i -H 'Authorization: Basic hi there' 'http://localhost:8080/test' -v * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 8080 (#0) > GET /test HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.54.0 > Accept: */* > Authorization: Basic hi > there > < HTTP/1.1 400 Bad Request HTTP/1.1 400 Bad Request < Content-Type: text/plain; charset=utf-8 Content