Skip to content

Commit

Permalink
Example for image response. #19
Browse files Browse the repository at this point in the history
  • Loading branch information
basicallydan committed Dec 4, 2015
1 parent 31aa017 commit 5af1071
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Binary file added examples-javascript/assets/20x20-image-redjpg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples-javascript/assets/20x20-image-redpng.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions examples-javascript/fluent-image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var Interfake = require('..');
var request = require('request'); // Let's use request for this example

var interfake = new Interfake({ debug: true });
interfake.get('/jay-peg').image('./examples-javascript/assets/20x20-image-redjpg.jpg');
interfake.get('/pee-en-gee').image('./examples-javascript/assets/20x20-image-redpng.png');
interfake.listen(3030); // The server will listen on port 3030

request('http://localhost:3030/jay-peg', function (error, response, body) {
console.log(response.headers['content-type']); // prints image/jpeg
});

request('http://localhost:3030/pee-en-gee', function (error, response, body) {
console.log(response.headers['content-type']); // prints image/png
});

0 comments on commit 5af1071

Please sign in to comment.