Skip to content

Latest commit

History

History
32 lines (23 loc) 路 1.07 KB

README.md

File metadata and controls

32 lines (23 loc) 路 1.07 KB

馃惃 Version Middleware 馃惃

Introduction

This add-on attaches app version information to outgoing responses. This is useful for debugging live services, especially during a blue/green deployment where different responses can come from different deployed versions.

It attaches two headers:

  • Server is set to ${appID.name}/${appID.version} e.g. seek-example-service/1234. This is the standard HTTP header for indicating the serving software. It has the disadvantage of being replaced by other servers on the response path such as Nginx.

  • X-API-Version is set to ${appID.version} e.g. 1234. This is a convention that originated from the Candidate team. Due to being non-standard this is typically preserved along the response path.

Usage

import { VersionMiddleware } from 'seek-koala';

// Pass an appID with our name and version
const appID = {
  name: 'ca-example-service',
  version: '1234',
};

// Attach version headers to all outgoing responses
const versionMiddleware = VersionMiddleware.create(appID);
app.use(versionMiddleware);