Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added hooks (generators) to be able to reliably and nicely tell when prerendering is going to happen or already has happened since they are only yielded to if the respective situation happens.
The
afterPrerender
is pretty useless if we consider that whatever hasyield
ed tokoa-prerender
will have control back and always have access to theX-Prerender
header and the context as well. I only added it for the sake of consistency.This makes it possible to cache the result and possibly save a decent amount of resources.
It will also no longer yield down the stack when prerendering happens. The reason for this is simple: it used to overwrite the body of the response anyway so letting it run down and up is just wasting resources. Any other things that are supposed to happen after it can now happen in the after hook, or in a middleware above it which will then have access to the
X-Prerender
header at all times.This is technically a breaking change, but in truth it only affects those who relied on this yield down the stack for some reason. Nevertheless it bumps the major
Closes #11
Possibly solves #9