From: Carl Worth Date: Sun, 5 Dec 2010 11:21:23 +0000 (-0800) Subject: Add a "show" action as well. X-Git-Url: https://git.cworth.org/git?p=nodemuch;a=commitdiff_plain;h=0f2625afe523247a0229511db1dbffba9dd560dc Add a "show" action as well. Much like search, but calling "notmuch show" instead. --- diff --git a/example.js b/example.js index 74e5701..fb57c91 100644 --- a/example.js +++ b/example.js @@ -3,12 +3,18 @@ var http = require( "http" ), exec = require( "child_process" ).exec; http.createServer( function(req, res) { - var url = parse( req.url ); - if ( url.pathname.split( "/" ).splice(-1)[0] === "search" ) { + var url = parse( req.url ), + action = url.pathname.split( "/" ).splice(-1)[0]; + if ( action === "search" ) { exec( "notmuch search " + url.query, function( error, stdout, stderr ) { res.writeHead( 200, { "Content-Type": "text/plain" } ); res.end( stdout ); }); + } else if ( action === "show" ) { + exec( "notmuch show " + url.query, function( error, stdout, stderr ) { + res.writeHead( 200, { "Content-Type": "text/plain" } ); + res.end( stdout ); + }); } else { res.writeHead( 404 ); res.end("404");