Skip to content
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

Verify template and layout files exist in handler #10

Closed
hueniverse opened this issue Nov 6, 2014 · 7 comments
Closed

Verify template and layout files exist in handler #10

hueniverse opened this issue Nov 6, 2014 · 7 comments
Assignees
Labels
bug
Milestone

Comments

@hueniverse
Copy link
Member

@hueniverse hueniverse commented Nov 6, 2014

Otherwise, rendering fails after onPreResponse is called. Use response 'prepare' option.

Replaces hapijs/hapi#1882

@hueniverse hueniverse added the bug label Nov 6, 2014
@hueniverse hueniverse added this to the 2.0.0 milestone Nov 6, 2014
@hueniverse hueniverse self-assigned this Nov 6, 2014
@hueniverse hueniverse removed this from the 2.0.0 milestone Nov 10, 2014
@jagoda

This comment has been minimized.

Copy link
Contributor

@jagoda jagoda commented Jul 7, 2015

@hueniverse you are assigned. Are you still looking at this? I may take a crack at it if you are not.

@hueniverse hueniverse removed their assignment Jul 7, 2015
@hueniverse

This comment has been minimized.

Copy link
Member Author

@hueniverse hueniverse commented Jul 7, 2015

Not anymore...

@jagoda jagoda self-assigned this Jul 7, 2015
@jagoda jagoda added this to the 2.0.2 milestone Jul 7, 2015
@jagoda

This comment has been minimized.

Copy link
Contributor

@jagoda jagoda commented Jul 8, 2015

After looking into this, it seems to me that the full rendering process should be moved to the prepare step and the results stored on the source object (to be retrieved during the marshal step)? Otherwise other errors (like file permissions, malformed options, etc.) may not get reported until after the onPreResponse event as well. It seems reasonable to still set the content-type in the marshal step though. @hueniverse do you have any concerns about this approach?

jagoda added a commit to jagoda/vision that referenced this issue Jul 8, 2015
Currently, rendering happens right before the response is sent to
the client. This means that errors and other rendering results are
not available to 'onPostHandler' and 'onPreResponse' handlers. This
change moves the rendering step to an earlier point in the request
lifecycle to allow the results to be processed after the handler
has completed.

Fixes hapijs#10.
@hueniverse

This comment has been minimized.

Copy link
Member Author

@hueniverse hueniverse commented Jul 8, 2015

The view context can change all the way until onPreResponse.

@jagoda

This comment has been minimized.

Copy link
Contributor

@jagoda jagoda commented Jul 8, 2015

Ah, I see. I'll see if I can come up with something better. Thanks for the tip!

@jagoda

This comment has been minimized.

Copy link
Contributor

@jagoda jagoda commented Jul 9, 2015

@hueniverse what if just the template compilation is done in the prepare step while the marshal step uses the compiled output to render the context? . Admittedly this is a bit more complicated than checking template and layout existence and means reworking the implementation a bit. However, I think it will expose a few more errors early in the request lifecycle (like file readability) without compromising the ability to modify the context object later in the lifecycle.

@hueniverse

This comment has been minimized.

Copy link
Member Author

@hueniverse hueniverse commented Jul 9, 2015

I'm open to it. Give it a try. Will probably need another person to do a full code review for such a major refactor.

jagoda added a commit to jagoda/vision that referenced this issue Jul 11, 2015
Currently neither template compilation nor rendering occur until
after the 'onPreResponse' event. This means that extensions have
no way to intercept template related errors. This change moves the
compilation step to an earlier point in the request lifecycle so
that compilation errors are made available to the 'onPostHandler'
and 'onPreResponse' extension points. Rendering still happens
after 'onPreResponse' so that the context object can be modified
by extensions all the up through the 'onPreResponse' event.

Fixes hapijs#10.
@jagoda jagoda modified the milestones: 3.0.0, 2.0.2 Jul 20, 2015
@jagoda jagoda closed this in #33 Aug 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.