PHP Classes

File: test/test2.js

Recommend this page to a friend!
  Classes of Nikos M.  >  Dromeo PHP Router Library  >  test/test2.js  >  Download  
File: test/test2.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: Update of test/test2.js
Date: 1 year ago
Size: 1,388 bytes


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

function defaultHandler()

var router = new Dromeo('');

        name: 'route1',
        handler: defaultHandler 
        name: 'route2',
        handler: defaultHandler 
        name: 'route4',
        handler: defaultHandler 
        name: 'route3',
        handler: defaultHandler 

function make(route, params, strict)
    var out;
    try {
        out = router.make(route, params, strict);
    } catch( err ) {
        out = err.message;
    return out;

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

echo(make('route1', {user:'foo',id:'123'}));
echo(make('route1', {user:'foo',id:'123'}, true));
echo(make('route1', {user:'foo'}));
echo(make('route2', {user:'foo'}));
echo(make('route2', {user:'foo',id:'123'}));
echo(make('route2', {user:'foo',id:'123'}, true));
echo(make('route3', {user:'foo',id:'123'}));
echo(make('route4', {user:'foo'}));
echo(make('route4', {user:'foo',id:'123',action:'test'}));
echo(make('route4', {user:'foo',action:'test'}, true));
For more information send a message to info at phpclasses dot org.