Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasrafael committed Jul 22, 2019
1 parent abca90e commit 68cec99
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ To use middleware is very simple, just import and then define your list of permi
const whitelist = require('ip-allowed');

// Create middleware.
const middleware = whitelist(['127.0.0.1', 'www.client.com'], options);
// Only requests the "localhost/127.0.0.1"
// and ip from the domain "client.com" will be accepted.
const middleware = whitelist(['127.0.0.1', 'client.com'], options);

// Injecting middleware into instance express
const express = require('express');
Expand All @@ -49,14 +51,14 @@ const options = {

> The options are not mandatory and have default values.
- **log**: Allows you to manipulate the log on each request. To disable log assign its value equal to `false`.
- Valor default:
- Default value:
```js
(clientIp, accessDenied) => {
console.log(`Access ${accessDenied ? 'denied' : 'allowed'} for ip address ${clientIp}`)
}
```
- **message**: Allows you to handle the error message when the client IP is not on the whitelist.
- Valor default:
- Default value:
```js
(err, clientIp) => {
return {
Expand All @@ -67,9 +69,9 @@ const options = {
}
```
- **statusCode**: The status code sent when the request was denied.
- Valor default: `401`
- Default value: `401`
- **redirectTo**: URL to redirect when request is denied. Be sure to set the statusCode to 301 or 302 as it is the HTTP status codes that apply in this situation. Otherwise, the default 401 will be used.
- Valor default: `""`
- Default value: `""`


[//]: # (These are reference links used in the body of this note.)
Expand Down

0 comments on commit 68cec99

Please sign in to comment.