Changes between Version 26 and Version 27 of members/GRIP-UQAM/Javascript


Ignore:
Timestamp:
Apr 4, 2017, 7:51:50 AM (3 years ago)
Author:
https://id.mayfirst.org/gripuqam
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • members/GRIP-UQAM/Javascript

    v26 v27  
    133133* [[Image(https://nodei.co/npm/mapleTree.png?downloads=true&downloadRank=true&stars=true, link=https://nodei.co/npm/mapleTree/, title=saambarati/mapleTree)]]
    134134* [[Image(https://nodei.co/npm/#.png?downloads=true&downloadRank=true&stars=true, link=https://nodei.co/npm/#/, title=)]]
     135{{{#!js
     136var route = require('path-match')({
     137  // path-to-regexp options
     138  sensitive: false,
     139  strict: false,
     140  end: false,
     141});
     142 
     143// create a match function from a route
     144var match = route('/post/:id');
     145 
     146// match a route
     147var parse = require('url').parse;
     148require('http').createServer(function (req, res) {
     149  var params = match(parse(req.url).pathname);
     150 
     151  // no match
     152  if (params === false) {
     153    res.statusCode = 404;
     154    res.end();
     155    return;
     156  }
     157 
     158  // the matched id
     159  var id = params.id;
     160 
     161  // do stuff with the ID
     162})
     163}}}
    135164== Authentication ==
    136165* [[Image(https://nodei.co/npm/passport.png?downloads=true&downloadRank=true&stars=true, link=https://nodei.co/npm/passport/, title=jaredhanson/passport)]][[Image(https://qa.debian.org/cgi-bin/popcon-png?packages=node-passport&show_installed=on&date_fmt=%25Y, 9%, link=https://tracker.debian.org/pkg/passportjs, title="debian: passportjs")]]