Skip to content

Instantly share code, notes, and snippets.

@egoist
Last active February 9, 2017 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egoist/9fc74423cece72c4c1652cfd0c30bc93 to your computer and use it in GitHub Desktop.
Save egoist/9fc74423cece72c4c1652cfd0c30bc93 to your computer and use it in GitHub Desktop.
const extract = require('path-extract')
const params = extract('/user/:username', '/user/egoist')
console.log(params)
//=>
{
username: 'egoist'
}
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