💡 The feature or bug you are proposing
Using bunrouter.JSON in handlers passed to either WithNotFoundHandler or WithMethodNotAllowedHandler results in application/text Content-Type header.
📄 The description of the bug or the logic behind your proposal
Constructing my router like this:
router := bunrouter.New(
bunrouter.WithMiddleware(reqLogMiddleware),
bunrouter.WithMiddleware(errorHandlerMiddleware),
bunrouter.WithNotFoundHandler(notFoundHandler),
bunrouter.WithMethodNotAllowedHandler(methodNotAllowedHandler),
)
Both of my notFoundHandler and methodNotAllowedHandler middlewares send a valid JSON response with:
Where err is a custom HTTPError type with json marshaling tags.
The JSON marshaling does work and the response received on the client is something like:
{"code":"not_found","message":"no route found for /"}
But the Content-Type header received is text/plain; charset=utf-8.
🚀 The expected result
bunrouter.JSON should always set application/json as the Content-Type, even when used in special middlewares.
💡 The feature or bug you are proposing
Using
bunrouter.JSONin handlers passed to eitherWithNotFoundHandlerorWithMethodNotAllowedHandlerresults inapplication/textContent-Type header.📄 The description of the bug or the logic behind your proposal
Constructing my router like this:
Both of my
notFoundHandlerandmethodNotAllowedHandlermiddlewares send a valid JSON response with:Where
erris a customHTTPErrortype withjsonmarshaling tags.The JSON marshaling does work and the response received on the client is something like:
But the Content-Type header received is
text/plain; charset=utf-8.🚀 The expected result
bunrouter.JSONshould always setapplication/jsonas the Content-Type, even when used in special middlewares.