https://github.com/awwright/gulp-http-server
An HTTP server with Gulp!
https://github.com/awwright/gulp-http-server
Last synced: about 1 month ago
JSON representation
An HTTP server with Gulp!
- Host: GitHub
- URL: https://github.com/awwright/gulp-http-server
- Owner: awwright
- Created: 2014-01-25T10:59:14.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-25T21:28:48.000Z (over 12 years ago)
- Last Synced: 2024-10-18T10:29:04.226Z (over 1 year ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gulp-http-server
A library for serving HTTP requests through a Gulp pipeline
Format Markdown files on your filesystem to HTML!
Format JSON into HTML!
Format HTML into PDFs!
DO ANYTHING!
## Example
See httpd.js for an example server:
$ node httpd.js
## Usage
var gulphttpd = require('gulp-http-server');
### gulphttpd.src(httpd, webroot, namespace)
Serve files out of `webroot` whenever `namespace` is asked for. Typically `namespace` should be `/`, but may also be an absolute URI like `http://example.com/`.
`webroot` must have a trailing `/`.
### gulphttpd.log([outstream])
Logs the request to outstream in the Common Log Format when the response is written. Defaults to stdout if not provided.
### gulphttpd.request(fn)
Calls `fn(file, req, res, next)` on every request so you can conduct HTTP-specific logic on an HTTP request. For instance, setting CORS headers or setting Content-Type based on the filename.
Call `next()` to pass the request along in the pipeline, or pass an error argument to trigger an error.
### gulphttpd.setHeader(name, value)
Calls response.setHeader on every HTTP request going through. Useful for setting the Content-Type, Server, or similar headers.
### gulphttpd.dest()
Writes the formatted file to the HTTP response, which was stored in the `stats.http` object during the `gulphttpd.src` call (so no arguments are needed).
This passes through the file object unmodified, so you may read from `stats.http.req` and `stats.http.res` to do logging or other operations.