Socket
Socket
Sign inDemoInstall

express-prefer

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    express-prefer

Prefer header for HTTP (RFC 7240)


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
12.1 kB
Created
Weekly downloads
 

Readme

Source

express-prefer Build Status

RFC 7240 defines an HTTP header field that can be used by a client to request that certain behaviors be employed by a server while processing a request.

This package parses the HTTP Request and makes the prefer headers a keyed property of req.prefer.

Getting started npm version

$ npm install express-prefer --save

then add to your server.js file

app.use(require('express-prefer'))

and That's all folks!

Usage

Given the following Request

PATCH /my-document HTTP/1.1
Host: example.org
Content-Type: application/json-patch+json
Prefer: return=representation

[{"op": "add", "path": "/a", "value": 1}]

then

app.patch('/:doc', (req,res,next) => {
    // Apply the patch ...
    
    // What should we return?
    if (req.prefer.return == 'representation')
        res.status(200).send(doc).end();
    else
        res.status(204).end();
})

License

The MIT license

Copyright © 2015 Richard Schneider (makaretu@gmail.com)

Keywords

FAQs

Last updated on 21 Jan 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc