Skip to content

Commit 182c76c

Browse files
committed
[api] export the httpProxy.Server as the main export but preserve the createServer factory
1 parent e599151 commit 182c76c

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

Diff for: lib/http-proxy.js

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
var http = require('http'),
22
https = require('https'),
33
url = require('url'),
4-
httpProxy = require('./http-proxy/'),
5-
proxy = exports;
4+
httpProxy = require('./http-proxy/');
5+
6+
/**
7+
* Export the "Server" so we can have an intuitive api for just creating
8+
* a proxy
9+
*
10+
*/
11+
module.exports = httpProxy.Server;
612

713
/**
814
* Creates the proxy server.
@@ -19,23 +25,23 @@ var http = require('http'),
1925
* @api public
2026
*/
2127

22-
proxy.createProxyServer = proxy.createServer = function createProxyServer(options) {
28+
module.exports.createProxyServer = module.exports.createServer = function createProxyServer(options) {
2329
/*
2430
* `options` is needed and it must have the following layout:
25-
*
26-
* {
27-
* target : <url string to be parsed with the url module>
28-
* forward: <url string to be parsed with the url module>
29-
* agent : <object to be passed to http(s).request>
30-
* ssl : <object to be passed to https.createServer()>
31+
*
32+
* {
33+
* target : <url string to be parsed with the url module>
34+
* forward: <url string to be parsed with the url module>
35+
* agent : <object to be passed to http(s).request>
36+
* ssl : <object to be passed to https.createServer()>
3137
* ws : <true/false, if you want to proxy websockets>
32-
* xfwd : <true/false, adds x-forward headers>
38+
* xfwd : <true/false, adds x-forward headers>
3339
* secure : <true/false, verify SSL certificate>
34-
* }
35-
*
36-
* NOTE: `options.ws` and `options.ssl` are optional.
37-
* `options.target and `options.forward` cannot be
38-
* both missing
40+
* }
41+
*
42+
* NOTE: `options.ws` and `options.ssl` are optional.
43+
* `options.target and `options.forward` cannot be
44+
* both missing
3945
* }
4046
*/
4147

0 commit comments

Comments
 (0)