-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Eliah-Lakhin/master
Support custom middlewares
- Loading branch information
Showing
7 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<html><body>test-string | ||
<script type="text/javascript">document.write('<script src="' + (location.protocol || 'http:') + '//' + (location.hostname || 'localhost') + ':35729/livereload.js?snipver=1" type="text/javascript"><\/script>')</script> | ||
</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><body>test-string</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
var serve = require('../'); | ||
var http = require('http'); | ||
var fs = require('fs'); | ||
var should = require('should'); | ||
|
||
require('mocha'); | ||
|
||
describe('static webserver', function() { | ||
describe('serving', function() { | ||
this.timeout(10000); | ||
|
||
it('should serve content', function(done) { | ||
var fixture = fs.readFileSync('./test/fixtures/raw-response.txt').toString(); | ||
|
||
serve('./test/server/')(); | ||
|
||
http.get('http://localhost:3000/', function(res) { | ||
res.on('data', function(body) { | ||
body.toString().should.equal(fixture); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should be able to modify serving content', function(done) { | ||
var fixture = fs.readFileSync('./test/fixtures/modified-response.txt').toString(); | ||
|
||
serve({ | ||
root: './test/server/', | ||
port: 3001, | ||
middleware: require('connect-livereload')({port: 35729}) | ||
})(); | ||
|
||
http | ||
.request( | ||
{ | ||
hostname: 'localhost', | ||
port: 3001, | ||
method: 'GET', | ||
headers: {'accept': 'text/html'} | ||
}, | ||
function(res) { | ||
res.on('data', function(body) { | ||
body.toString().should.equal(fixture); | ||
done(); | ||
}); | ||
} | ||
) | ||
.end(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><body>test-string</body></html> |