question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using unless path with HTTP Methods

See original GitHub issue

How does one go about using the .unless function passing a path array while also specifying http methods?

I want restrict POST requests to certain routes but not GET requests.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
goncalonevescommented, Jul 10, 2015

@twistedstream I had this issue, to have exceptions depending on request method. Could do a PR on readme with an example very suitable for this, such as:

app.use(jwt({ secret: 'shhhhhhared-secret'}).unless(function(req) {
  return (
    req.originalUrl === '/endpoint1' && req.method === 'GET' ||
    req.originalUrl === '/endpoint2' && req.method === 'POST'
  );
}));
0reactions
rphovleycommented, Aug 8, 2017

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can i specify a Http Method for a specific route in express ...
i'm using express-jwt to restrict access to my API routes. app.use(expressJWT( { secret: process.env.JWT_PASSPHRASE }) ...
Read more >
Using HTTP Methods for RESTful Services - REST API Tutorial
HTTP methods tutorial on how to use them for RESTful API or Web Service. ... PATCH, Update/Modify, 405 (Method Not Allowed), unless you...
Read more >
9 HTTP methods and how to use them - Testfully
This article will go through different HTTP methods and how to use them when building and using web APIs. Table of Contents ...
Read more >
HTTP/1.1: Method Definitions
The conditional GET method is intended to reduce unnecessary network usage by allowing cached entities to be refreshed without requiring multiple requests or ......
Read more >
How To Define Routes and HTTP Request Methods in Express
HTTP methods provide additional functionality to your data using the POST , PUT , and DELETE requests. The POST request method creates new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found