Wildcard Method Requests
See original GitHub issueDescription
The current method implementations don’t support catch-all endpoints.
Requested Syntax
const server = require('server');
const { status } = server.reply;
const { get } = server.router;
server(
// This should get invoked for every request
// An alternative syntax would be to support Regular Expressions.
get('*', (ctx) => {
return status(200);
})
);
Current Workaround
const server = require('server');
const { status } = server.reply;
server(
(ctx) => {
if (ctx.method !== 'GET') return;
// Do super cool api stuff
return status(200);
})
);
Relevant Code
The following code doesn’t support wildcards / catch-all endpoints.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (12 by maintainers)
Top Results From Across the Web
java - When to use generic methods and when to use wild-card?
If you want to enforce some relationship on the different types of method arguments, you can't do that with wildcards, you have to...
Read more >URL Query Parameter Wildcard
Purpose: Identifies requests by whether a query string parameter in the requested URL matches a pattern defined by a wildcardThis type of value...
Read more >Access-Control-Allow-Methods - HTTP - MDN Web Docs
A comma-delimited list of the allowed HTTP request methods. * (wildcard). The value " * " only counts as a special wildcard value...
Read more >Searching with a wildcard character - BMC Documentation
Searching with a wildcard character. Users can use the percent sign (%) wildcard for any type of search to broaden the set of...
Read more >Wildcard Query Parameter Support - TechDocs - Broadcom Inc.
This section provides a couple of basic examples for using the wildcard (*) search. Retrieving a List of Switches. The following sample request...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi guys. Yes, I should probably consider to remove the asterisk and migrate the module to version
2.x
ofpath-to-regexp
.I upgraded server to 1.0.7, please @nick-woodward let me know if this fixes the issue for you. I fixed the
path-to-regexp
version and hardcodedpath-to-regexp-wrap
. So it should install the right version and work as expected with both yarn and npm.For version
2.0
of server I don’t know if we will depend on express or not; if we do, it’ll be very likely5.0
. I close this as I am really not sure what will happen by then and it’s still quite far away.