From b119af801825a804a2431059fde1cdde57022e9d Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 13 Mar 2018 21:25:39 +0100 Subject: [PATCH] Updated example --- example.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/example.js b/example.js index 5891b58..5b428c2 100644 --- a/example.js +++ b/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) })