Skip to content

Instantly share code, notes, and snippets.

@Dirrk
Created April 1, 2016 14:37
Show Gist options
  • Select an option

  • Save Dirrk/fe664c448435e472ffd10afa35925ebf to your computer and use it in GitHub Desktop.

Select an option

Save Dirrk/fe664c448435e472ffd10afa35925ebf to your computer and use it in GitHub Desktop.

Revisions

  1. Dirrk created this gist Apr 1, 2016.
    28 changes: 28 additions & 0 deletions test-retries.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    'use strict';

    /*
    npm install [email protected]
    node thisfile.js
    curl -XPOST http://localhost:4000/v1/lead/property
    */
    var Hapi = require('hapi');
    var server = new Hapi.Server();
    var count = 0;
    server.connection({ port: 4000 });

    server.route([
    {
    method: 'POST',
    path: '/v1/lead/property',
    handler: function (request, reply) {
    count++;
    if (count % 2 === 0) {
    return reply({success: true});
    }
    reply(new Error('Invalid count'));
    }
    }
    ]);

    server.start();