call

HTTP Router

This module has moved and is now available at @hapi/call. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
Last updated 2 years ago by hueniverse .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install call 
SYNC missed versions from official npm registry.

call - Simple HTTP Router

Build Status

Lead Maintainer - Eran Hammer

Introduction

call is a simple node.js HTTP Router. It is used by popular hapi.js web framework. It implements predictable and easy to use routing. Even if it is designed to work with Hapi.js, you can still use it as an independent router in your app.

Example

const Call = require('call');

// Create new router
const router = new Call.Router();

// Add route
router.add({ method: 'get', path: '/' }, { label: 'root-path' });

// Add another route
router.add({ method: 'post', path: '/users' }, 'route specific data');

// Add another route with dynamic path
router.add({ method: 'put', path: '/users/{userId}' }, () => { /* ...handler... */ });

// Match route
router.route('post', '/users');
/* If matching route is found, it returns an object containing
    {
        params: {},                     // All dynamic path parameters as key/value
        paramsArray: [],                // All dynamic path parameter values in order
        route: 'route specific data';   // routeData
    }
*/


// Match route
router.route('put', '/users/1234');
/* returns
    {
        params: { userId: '1234' },
        paramsArray: [ '1234' ],
        route: [Function]
    }
*/

API

See the detailed API Reference.

Current Tags

  • 5.0.3                                ...           latest (2 years ago)

16 Versions

  • 5.0.3 [deprecated]           ...           2 years ago
  • 5.0.2 [deprecated]           ...           2 years ago
  • 5.0.1 [deprecated]           ...           3 years ago
  • 5.0.0 [deprecated]           ...           3 years ago
  • 4.0.2 [deprecated]           ...           3 years ago
  • 4.0.1 [deprecated]           ...           3 years ago
  • 4.0.0 [deprecated]           ...           3 years ago
  • 3.0.4 [deprecated]           ...           4 years ago
  • 3.0.3 [deprecated]           ...           4 years ago
  • 3.0.2 [deprecated]           ...           4 years ago
  • 3.0.1 [deprecated]           ...           4 years ago
  • 3.0.0 [deprecated]           ...           5 years ago
  • 2.0.2 [deprecated]           ...           5 years ago
  • 2.0.1 [deprecated]           ...           6 years ago
  • 2.0.0 [deprecated]           ...           6 years ago
  • 1.0.0 [deprecated]           ...           6 years ago

Copyright 2014 - 2016 © taobao.org |