Open
Description
Appologize for the gif. However a gif is worth 1000 words. π
The following code is running from snuggsi γ:
const
root = 'mixins'
, mime = /^\*\/\*$/
, filter = /^\/mixins\/(.*\.es)*$/g
, send = require ('koa-send')
module.exports = async (context, next) => {
const
match = filter.test (context.path)
, resource = './storable.es'
, settings = [context, resource, { root }]
, header = ['Content-Type', 'application/ecmascript']
, response = match && await send ( ... settings )
void (response && context.set ( ... header ))
|| await next ()
console.log ('response', context.response, response)
}
By the way it's a little wonky to change headers AFTER send is called. (which just returns a file path anyways). Let me know where I can help. PR. etc.
Thanks in advance @tj
Metadata
Assignees
Labels
No labels