New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preSerialization are not executed when content-type is set #5282
Comments
If I'm reading things correctly, the reproduction should hit line 189 in: Lines 162 to 215 in ac26d7b
If it's not, I'd classify that as a bug. |
Nope, it goes to: Line 217 in ac26d7b
|
That seems very wrong. |
How can you expect to have |
I was expecting it to be executed since I did not provide any response that is already serialized. We are blocking the possibility of configuring a hook to work like a serializer. I would write down that the
Anyway, should we improve the usability? I'm thinking something like:
|
What I come in mind is we should do something like fastify.addContentTypeSerializer('text/xml', function (reply, payload, done) {
done('')
}) Better support would be fastify.addContentType('text/xml', {
// output for reply
serialize: (reply, payload, done) => {},
// input for request
deserialize: (request, payload, done) => {}
}) |
I'd try to implement something for this, if no one is working on it. |
@Eomm There was never the intention to call that hook in this situation because it lead to having a gigantic if based on the content type. |
Prerequisites
Fastify version
latest
Plugin version
No response
Node.js version
20
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Description
The
preSerialization
hooks do not run when thecontent-type
is customized:Steps to Reproduce
Expected Behavior
I think we should run the
preSerialization
hooks when a customcontent-type
is set.Do we force the user to write?
WDYT?
The text was updated successfully, but these errors were encountered: