trekjs / router Goto Github PK
View Code? Open in Web Editor NEW⚡ A fast HTTP router, inspired by Echo's Router
License: MIT License
⚡ A fast HTTP router, inspired by Echo's Router
License: MIT License
Is it possible to add RegExp support ... If possible, will that be have any impact on performance?
/users/new
/users/:id
/users/nnn
Right behaviour: match /users/:id
Hi @fundon,
I was created a Router for Koa based on Trek-Router.
I want to support 405 method not allowed
and 501 path not implemented
as you can see here but I can't do that with the current result of find
method because we don't have any indicator about path was finded or not.
So, if there is any other way to get what I ask. or please add something added to result to be like that;
const route = TrekRouter.find(method, path)
const [handler, params, findedPath] = route
// !handler && findedPath === false => 501 path not implemented.
// !handler && findedPath === true => 405 method not allowed.
before
let result = router.find('GET', '/users/233')
// => [handler, params]
// => [()=>{}, [{name: id, value: 233}]]
after
let result = router.find('GET', '/users/233')
// => [handler, params]
// => [()=>{}, {id: 233}]
n--
console.log("before", params);
params.shift()
console.log("after", params);
search = preSearch
I think the params.shift() should be params.pop().
shift() will pop from front, and pop() will pop from back.
In this case, I think it should pop from back.
I use the following case for debug:
['GET', '/:prefix/people/:userId/activities/:collection', '/xxx/people/377/activities/333'],
['GET', '/:prefix/people/*', '/xxx/people/377/activities'],
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.