You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
They are replicating the core Reply methods and should behave accordingly. In fact, I'm not sure why the view decoration is on the server object. Views should be rendered in the context of a request, and in particular the context of sending a reply. So I would think the view decoration should be fastify.decorateReply('view', function () {}). Which would mean the following would be an outline of a solution:
fastify.decorateReply('view',function(){// other details omittedrenderer.apply({getHeader, header},args)functiongetHeader(key){returnthis.getHeader(key)}functionheader(key,val){returnthis.header(key,val)}})
I would like to pick up this issue, if this is OK with you?
If I understood correctly, there are two issues at hand:
the extension should decorate the reply object, not the server (it would be a breaking change, wouldn't it?)
calls to the getHeader and header functions are not chainable, so they don't adhere to the way it is done in the framework and as for now have no implementation and just return empty objects
The actual options for
getHeader
is not compliant to the fastify codebase that support the chaining-call:ex:
this.header('Content-Type', 'text/html; charset=' + charset).send(html)
It would be awsome if @momofan or @florianb could work on this 💪
Mode info on how to implement this improvement:
point-of-view/index.js
Lines 52 to 53 in b7345f0
They are replicating the core
Reply
methods and should behave accordingly. In fact, I'm not sure why theview
decoration is on the server object. Views should be rendered in the context of a request, and in particular the context of sending a reply. So I would think theview
decoration should befastify.decorateReply('view', function () {})
. Which would mean the following would be an outline of a solution:Originally posted by @jsumners in #129
The text was updated successfully, but these errors were encountered: