Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lsongdev/routing2
:triangular_flag_on_post: Parse HTTP Routing definition with no dependencies, just ~3kb!
https://github.com/lsongdev/routing2
http http-routing router routing
Last synced: 3 days ago
JSON representation
:triangular_flag_on_post: Parse HTTP Routing definition with no dependencies, just ~3kb!
- Host: GitHub
- URL: https://github.com/lsongdev/routing2
- Owner: lsongdev
- License: isc
- Created: 2017-08-08T03:29:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-10T02:14:29.000Z (over 5 years ago)
- Last Synced: 2024-12-31T10:05:36.900Z (5 days ago)
- Topics: http, http-routing, router, routing
- Language: JavaScript
- Homepage: https://npmjs.org/routing2
- Size: 48.8 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## routing2
> Parse HTTP Routing definition with no dependencies, just ~3kb!
[![routing2](https://img.shields.io/npm/v/routing2.svg)](https://npmjs.org/routing2)
[![Build Status](https://travis-ci.org/song940/routing2.svg?branch=master)](https://travis-ci.org/song940/routing2)### Define
### Installation
```bash
$ npm install routing2
```### Example
```js
const routing = require('routing2');const routes = routing.parse(`
get / => home#index
get /:name => user#index, { "foo": "bar" }
post /user => user#create
`);const request = {
method: 'get',
url: '/lsong?foo=bar'
};const route = routing.find(routes, request);
console.log(route);
// { status: 200,
// route:
// { domain: undefined,
// path: '/:name',
// action: 'index',
// controller: 'user',
// options: { foo: "bar" },
// method: 'GET' },
// params: { name: 'lsong' },
// query: { foo: 'bar' } }
```### Contributing
- Fork this Repo first
- Clone your Repo
- Install dependencies by `$ npm install`
- Checkout a feature branch
- Feel free to add your features
- Make sure your features are fully tested
- Publish your local branch, Open a pull request
- Enjoy hacking <3### MIT
This work is licensed under the [MIT license](./LICENSE).
---