Skip to content

Commit 9fb7a83

Browse files
committed
Update readme.md
Update readme to use syntax highlighting
1 parent f09e175 commit 9fb7a83

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

readme.md

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,52 +24,58 @@ At its simplest, the following will instantiate a non-authenticating transparent
2424
proxy that forwards requests to the target url without relaying the request
2525
through a third-party proxy:
2626

27-
var RelayProxy = require('./path/to/relay-proxy');
28-
var server = new RelayProxy();
29-
server.listen(3333);
27+
```js
28+
var RelayProxy = require('./path/to/relay-proxy');
29+
var server = new RelayProxy();
30+
server.listen(3333);
31+
```
3032

3133
### Local authorization
3234

3335
To authorize access to your proxy, provide a handler function:
3436

35-
var RelayProxy = require('./path/to/relay-proxy');
36-
var server = new RelayProxy();
37-
38-
server.authorize(function(req, username, password, callback) {
39-
// replace with code to verify username and password
40-
var isLoginCorrect = true;
41-
42-
// call the supplied callback function to continue the request
43-
callback(null, isLoginCorrect);
44-
});
37+
```js
38+
var RelayProxy = require('./path/to/relay-proxy');
39+
var server = new RelayProxy();
40+
41+
server.authorize(function(req, username, password, callback) {
42+
// replace with code to verify username and password
43+
var isLoginCorrect = true;
4544

46-
server.listen(3333);
45+
// call the supplied callback function to continue the request
46+
callback(null, isLoginCorrect);
47+
});
48+
```
49+
50+
server.listen(3333);
4751

4852
### Using a remote proxy
4953

5054
To forward requests via a third-party proxy, provide a handler function:
5155

52-
var RelayProxy = require('./path/to/relay-proxy');
53-
var server = new RelayProxy();
56+
```js
57+
var RelayProxy = require('./path/to/relay-proxy');
58+
var server = new RelayProxy();
59+
60+
server.selectForwardProxy(function(req, username, callback) {
5461

55-
server.selectForwardProxy(function(req, username, callback) {
56-
57-
var proxy = {
58-
host: '1.2.3.4',
59-
port: 31337,
60-
username: 'jimbob', // only supply a username and password if
61-
password: 'mcgee' // the remote proxy requires authorization
62-
};
63-
64-
// the callback's second argument can be one of three values:
65-
// null: no remote proxy - forward directly to the requested url
66-
// false: decline to forward the request (http 407 sent back to client)
67-
// proxy: proxy options as specified in the above sample
68-
69-
callback(null, proxy);
70-
});
62+
var proxy = {
63+
host: '1.2.3.4',
64+
port: 31337,
65+
username: 'jimbob', // only supply a username and password if
66+
password: 'mcgee' // the remote proxy requires authorization
67+
};
7168

72-
server.listen(3333);
69+
// the callback's second argument can be one of three values:
70+
// null: no remote proxy - forward directly to the requested url
71+
// false: decline to forward the request (http 407 sent back to client)
72+
// proxy: proxy options as specified in the above sample
73+
74+
callback(null, proxy);
75+
});
76+
77+
server.listen(3333);
78+
```
7379

7480
## Dependencies
7581

0 commit comments

Comments
 (0)