flowmemo / koa-httpany

response http status and headers according query string

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

koa-httpany

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.

Travis Coveralls branch npm

Installation

$ npm install koa-httpany@next

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 contain "foo: bar" and "answer: 42".

WARNING

Don't use this middleware in a production environment for safety considerations.

License

MIT © flowmemo

About

response http status and headers according query string


Languages

Language:JavaScript 100.0%