Skip to content

Instantly share code, notes, and snippets.

@d1egoaz
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save d1egoaz/ccbba154a39fad70e647 to your computer and use it in GitHub Desktop.

Select an option

Save d1egoaz/ccbba154a39fad70e647 to your computer and use it in GitHub Desktop.

Revisions

  1. d1egoaz revised this gist Mar 4, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nodeMock.js
    Original file line number Diff line number Diff line change
    @@ -22,5 +22,5 @@ app.get('/proxy2/:token?', function (req, res) {
    app.listen(9042);

    // test
    // curl http://localhost:9042/proxy/testtoken
    // curl -v http://localhost:9042/proxy2/testtoken
    // curl http://localhost:9042/proxy/testtoken Res: HTTP 200, {"name":"d1egoaz"}
    // curl http://localhost:9042/proxy2/testtoken Res: HTTP 400, Error 404: Not found proxy2
  2. d1egoaz created this gist Mar 4, 2015.
    26 changes: 26 additions & 0 deletions nodeMock.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    var express = require('express');
    var request = require('request');
    var app = express();

    app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
    });

    app.get('/proxy/:token?', function (req, res) {
    var j={"name":"d1egoaz"};
    res.json(j);
    });


    app.get('/proxy2/:token?', function (req, res) {
    res.statusCode = 404;
    return res.send('Error 404: Not found proxy2');
    });

    app.listen(9042);

    // test
    // curl http://localhost:9042/proxy/testtoken
    // curl -v http://localhost:9042/proxy2/testtoken