https://github.com/paulkinlan/leviroutes
A basic routes framework for JS that hooks in to HTML5 history
https://github.com/paulkinlan/leviroutes
Last synced: 5 months ago
JSON representation
A basic routes framework for JS that hooks in to HTML5 history
- Host: GitHub
- URL: https://github.com/paulkinlan/leviroutes
- Owner: PaulKinlan
- License: apache-2.0
- Created: 2011-03-31T03:36:48.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2019-04-13T11:39:32.000Z (about 6 years ago)
- Last Synced: 2024-12-12T22:06:11.024Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 229
- Watchers: 10
- Forks: 25
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
LeviRoutes
==========A simple lightweight routes framework for hooking in to HTML5 history. Currently when the system pop's state the route is triggered if matched.
var app = new routes();
app.get("/", function(req) {
alert("State popped for /");
});It also has named parameters for route syntax.
app.get("/:category", function(req) {
alert("In " + req.params.category);
});app.get("/:category.:format", function(req) {
alert("format: " + req.params.format);
});LeviRoutes can also intercept POST requests via forms, intercept all submits, and naturally let through requests that don't match the path, whilst firing your callback if there is a match.
app.post("/:category", function(req) {
alert("posting form: In Category " + req.params.category);
});