How to middleware to recursive fetches (ESI subrequests)
Here's a gist of where I'm at: https://gist.github.com/timkelty/8809fb0c0cbc9e840fa421376ab28a8b
7 Replies
Yeah I can see a number of issues already.
I'll leave a review later (just got off work)
Thanks!
Look right! I’ll give it a shot
Although…ideally I wanted mw after the esi stuff too
timing specifically (for the whole request)
I guess I could just do that with the app.get, right?
Why the
app.get('*')
vs use
?
Wont that only match GET reqs?You want to cache the response, that only makes sense when it's a GET request.
Why would you cache the response for say a POST request?
Also, .use is for middleware only
If you want to handle multiple http verbs, use .on
.on(["GET", "POST"], "*", (ctx) => {})
I only want to cache GETs, yes – but I still need everything running through parser.
.use is for middleware onlyDoesn't it being a fn that takes context as an arg and possibly return a response make it a middleware? Like, what would the difference be between: and Seems like it would be the same?
there is a difference alright, you are not calling
next
ok, after testing locally, it looks like that makes no difference