Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

README improvements #21

Merged
merged 1 commit into from

2 participants

@tdubourg

The require() statements were missing in the code samples.

It was also a bit unclear about where to actually put the requests handling logic (the samples were displaying "hello" + username (in short) and we could thus think that it is a kind of one-time callback...). I just added some comments.

tdubourg Fixing the readme (missing require()) + adding useful comments about …
…where to actually put the request handling logic when authenticating
10f83bd
@gevorg gevorg merged commit bc9cad6 into gevorg:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 7, 2013
  1. Fixing the readme (missing require()) + adding useful comments about …

    tdubourg authored
    …where to actually put the request handling logic when authenticating
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 1 deletion.
  1. +9 −1 README.md
View
10 README.md
@@ -20,6 +20,7 @@ $ npm install http-auth
/**
* Requesting new authentication instance.
*/
+var auth = require('http-auth')
var basic = auth({
authRealm : "Private area.",
// username is mia, password is supergirl.
@@ -32,6 +33,7 @@ var basic = auth({
http.createServer(function(req, res) {
// Apply authentication to server.
basic.apply(req, res, function(username) {
+ // Your request handling logic goes there
res.end("Welcome to private area - " + username + "!");
});
}).listen(1337);
@@ -41,6 +43,7 @@ http.createServer(function(req, res) {
/**
* Requesting new authentication instance.
*/
+var auth = require('http-auth')
var basic = auth({
authRealm : "Private area.",
authFile : __dirname + '/users.htpasswd'
@@ -52,6 +55,7 @@ var basic = auth({
http.createServer(function(req, res) {
// Apply authentication to server.
basic.apply(req, res, function(username) {
+ // Your request handling logic goes there
res.end("Welcome to private area, " + username + "!");
});
}).listen(1337);
@@ -61,6 +65,7 @@ http.createServer(function(req, res) {
/**
* Requesting new authentication instance.
*/
+var auth = require('http-auth')
var basic = auth({
authRealm : "Private area.",
authList : ['Shi:many222', 'Lota:123456']
@@ -71,6 +76,7 @@ var basic = auth({
*/
app.get('/', function(req, res) {
basic.apply(req, res, function(username) {
+ // Your request handling logic goes there
res.send("Welcome to private area - " + username + "!");
});
});
@@ -80,6 +86,7 @@ app.get('/', function(req, res) {
/**
* Requesting new authentication instance.
*/
+var auth = require('http-auth')
var basic = auth({
authRealm : "Private area.",
authList : ['mia:supergirl', 'Carlos:test456', 'Sam:oho'],
@@ -102,7 +109,8 @@ httpProxy.createServer(function(req, res, proxy) {
* Destination server.
*/
http.createServer(function(req, res) {
- res.end('request successfully proxied!');
+ // Your request handling logic goes there
+ res.end('request successfully proxied!');
}).listen(9000);
```
## Configurations
Something went wrong with that request. Please try again.