All Projects → jshttp → On Headers

jshttp / On Headers

Licence: mit
Execute a listener when a response is about to write headers.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to On Headers

Opendataday
Open Data Day website
Stars: ✭ 70 (-46.56%)
Mutual labels:  event
Nuxt Netlify
Dynamically generate `_headers` and `_redirects` files for Netlify in your Nuxt.js projects
Stars: ✭ 97 (-25.95%)
Mutual labels:  headers
Illuminati
This is a Platform that collects all the data accuring in your Application and shows the data in real time by using Kibana or other tools.
Stars: ✭ 106 (-19.08%)
Mutual labels:  event
Ease
It's magic.
Stars: ✭ 1,213 (+825.95%)
Mutual labels:  event
Kiss Headers
💡Python package for HTTP/1.1 style headers. Parse headers to objects. Most advanced available structure for http headers.
Stars: ✭ 91 (-30.53%)
Mutual labels:  headers
Geotic
Entity Component System library for javascript
Stars: ✭ 97 (-25.95%)
Mutual labels:  event
Lily
LÖVE Async Asset Loader
Stars: ✭ 64 (-51.15%)
Mutual labels:  event
Sgf
This is a Smart Game Foundation (Not Framework)
Stars: ✭ 122 (-6.87%)
Mutual labels:  event
Xer.cqrs
A lightweight and easy-to-use CQRS + DDD library
Stars: ✭ 96 (-26.72%)
Mutual labels:  event
Securityheaders
Check any website (or set of websites) for insecure security headers.
Stars: ✭ 104 (-20.61%)
Mutual labels:  headers
Rxbus
Android reactive event bus that simplifies communication between Presenters, Activities, Fragments, Threads, Services, etc.
Stars: ✭ 79 (-39.69%)
Mutual labels:  event
V Dragged
Vue directive plugin for drag event detection.
Stars: ✭ 84 (-35.88%)
Mutual labels:  event
Kitura Net
Kitura networking
Stars: ✭ 98 (-25.19%)
Mutual labels:  headers
Bekit
bekit框架致力于解决在应用开发中的公共性痛点,已有“事件总线”、“流程引擎”、“服务引擎”。其中“流程引擎”可作为分布式事务解决方案saga模式的一种实现,并且它很轻量不需要服务端、不需要配置,就可直接使用。
Stars: ✭ 71 (-45.8%)
Mutual labels:  event
Poweradapter
Adapter for RecyclerView(only 21KB).RecyclerView万能适配器(仅21KB)
Stars: ✭ 112 (-14.5%)
Mutual labels:  headers
Eventpp
Minimal C++ Event Bus
Stars: ✭ 69 (-47.33%)
Mutual labels:  event
Android Meetup 2016 08 07
Stars: ✭ 98 (-25.19%)
Mutual labels:  event
Metronome
Metronome is a distributed and fault-tolerant event scheduler
Stars: ✭ 131 (+0%)
Mutual labels:  event
Neventlite
NEventLite - An extensible lightweight library for .NET that manages the Aggregate lifecycle in an Event Sourced system. Supports Event and Snapshot storage providers like EventStore/Redis or SQL Server. Built with dependency injection in mind and seamlessly integrates with AspNetCore.
Stars: ✭ 117 (-10.69%)
Mutual labels:  event
Knot.js
A browser-based event emitter, for tying things together.
Stars: ✭ 100 (-23.66%)
Mutual labels:  event

on-headers

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Execute a listener when a response is about to write headers.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install on-headers

API

var onHeaders = require('on-headers')

onHeaders(res, listener)

This will add the listener listener to fire when headers are emitted for res. The listener is passed the response object as it's context (this). Headers are considered to be emitted only once, right before they are sent to the client.

When this is called multiple times on the same res, the listeners are fired in the reverse order they were added.

Examples

var http = require('http')
var onHeaders = require('on-headers')

http
  .createServer(onRequest)
  .listen(3000)

function addPoweredBy () {
  // set if not set by end of request
  if (!this.getHeader('X-Powered-By')) {
    this.setHeader('X-Powered-By', 'Node.js')
  }
}

function onRequest (req, res) {
  onHeaders(res, addPoweredBy)

  res.setHeader('Content-Type', 'text/plain')
  res.end('hello!')
}

Testing

$ npm test

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].