Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-Umar committed Sep 19, 2022
1 parent 2600c87 commit 4400d69
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ request.env['ipinfo'].all ==
In addition to the steps listed in the Installation section it is possible to configure the library with more detail. The following arguments are allowed and are described in detail below.

```ruby
require 'ipinfo-rails/ipselector/xforwarded_ipselector'
config.middleware.use(IPinfoMiddleware, {
token: "<your_token>",
ttl: "",
Expand All @@ -129,8 +130,31 @@ config.middleware.use(IPinfoMiddleware, {
http_client: "",
countries: "",
filter: "",
ipselector: XForwardedIPSelector,
})
```
### IP Selection Mechanism

By default, the IP is used by ignoring the reverse proxies depending on whether we are behind a reverse proxy or not.

Since the desired IP by your system may be in other locations, the IP selection mechanism is configurable and some alternative built-in options are available.
Using built-in IP selectors

- [DefaultIPSelector](./lib/ipinfo-rails/ipselector/default_ipselector.rb)
- [XForwardedIPSelector](./lib/ipinfo-rails/ipselector/xforwarded_ipselector.rb)

#### Using a custom IP selector

In case a custom IP selector is required, you may implement the `IPSelectorInterface` and pass the class to `ipselector` in config.
```ruby
require 'custom-package/custom_ipselector'
config.middleware.use(IPinfoMiddleware, {
token: "<your_token>",
ipselector: CustomIPSelector,
})
```



### Authentication

Expand Down

0 comments on commit 4400d69

Please sign in to comment.