From 0f2625afe523247a0229511db1dbffba9dd560dc Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 5 Dec 2010 03:21:23 -0800 Subject: [PATCH] Add a "show" action as well. Much like search, but calling "notmuch show" instead. --- example.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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"); -- 2.43.0