Skip to content

Commit

Permalink
Updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor committed Mar 13, 2018
1 parent b2c67c2 commit b119af8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions example.js
@@ -1,14 +1,25 @@
'use strict'

const http = require('http')
const router = require('./')()
const router = require('./')({
defaultRoute: (req, res) => {
res.end('not found')
}
})

router.on('GET', '/test', (req, res, params) => {
res.end('{"hello":"world"}')
})

router.on('GET', '/:test', (req, res, params) => {
res.end(JSON.stringify(params))
})

router.on('GET', '/text/hello', (req, res, params) => {
res.end('{"winter":"is here"}')
})

const server = http.createServer((req, res) => {
console.log(req.url)
router.lookup(req, res)
})

Expand Down

0 comments on commit b119af8

Please sign in to comment.