Last active
February 9, 2017 13:28
-
-
Save egoist/9fc74423cece72c4c1652cfd0c30bc93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const extract = require('path-extract') | |
const params = extract('/user/:username', '/user/egoist') | |
console.log(params) | |
//=> | |
{ | |
username: 'egoist' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import routage from 'routage' | |
const router = routage([ | |
{ | |
path: '/', | |
render() { | |
console.log('home') | |
} | |
}, | |
{ | |
path: '/about', | |
render() { | |
console.log('about') | |
} | |
}, | |
{ | |
path: '/user/:username', | |
render(params) { | |
console.log(`Hi ${params.username}`) | |
} | |
} | |
]) | |
router.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment