koa middleware that makes your app response with arbitrary http status and headers, based on user's query string.
master
branch is for koa v2. For koa 1.x support, see the koa.v1
branch.
$ npm install koa-httpany@next
'use strict'
var Koa = require('koa')
var httpAny = require('.')
var app = new Koa()
app.use(httpAny.anyStatus)
app.use(httpAny.anyHeader)
app.use((ctx, next) => {
ctx.body = JSON.stringify(ctx, null, 2)
return next()
})
app.listen(3000)
console.log('open http://localhost:3000/?status=201&foo=bar&answer=42 to see result')
You can see that response http status is 201, and headers contain "foo: bar" and "answer: 42".
Don't use this middleware in a production environment for safety considerations.
MIT © flowmemo