PHP Classes

File: test/js/test4.js

Recommend this page to a friend!
  Classes of Nikos M.  >  Dromeo PHP Router Library  >  test/js/test4.js  >  Download  
File: test/js/test4.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Dromeo PHP Router Library
Route HTTP requests to functions with URL patterns
Author: By
Last change:
Date: 1 month ago
Size: 1,029 bytes
 

Contents

Class file image Download
"use strict";
var path = require('path'),
    Dromeo = require(path.join(__dirname, '../../src/js/Dromeo.js')),
    echo = console.log, stringify = JSON.stringify
;

function defaultHandler(route)
{
    echo('Default Handler');
    echo(route);
}

var router = new Dromeo();

router.onGroup('/foo', function(router) {
    router
        .on({
            'route': '/koo',
            'method': '*',
            'handler': defaultHandler
        })
        .onGroup('/moo', function(router) {
            router
                .on({
                    'route': '',
                    'method': '*',
                    'handler': defaultHandler
                })
                .on({
                    'route': '/soo',
                    'method': '*',
                    'handler': defaultHandler
                })
            ;
        })
    ;
});

echo('Dromeo.VERSION = ' + Dromeo.VERSION);
echo();

router.route('/foo/koo', '*', true);
router.route('/foo/moo', '*', true);
router.route('/foo/moo/soo', '*', true);
For more information send a message to info at phpclasses dot org.