koa-httpany
v0.1.5
Published
response with arbitrary http status and headers based on query string
Downloads
3
Readme
koa-httpany
koa middleware that make your app response with arbitrary http status and headers, based on query string. Only support koa v2.x
Installation
$ npm install koa-httpany
Example
'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 contains "foo: bar" and "answer: 42".
WARNING
Don't use this middleware in production environment for safety considerations.
License
MIT © flowmemo