Skip to content

Commit

Permalink
Merge pull request #17 from ipinfo/uman/init-client-once
Browse files Browse the repository at this point in the history
Initialize php sdk client once at config
  • Loading branch information
UmanShahzad authored Jan 15, 2021
2 parents 0cf3810 + ee83f91 commit 25e5904
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to `ipinfolaravel` will be documented in this file.

## v2.1.3

- The IPinfo PHP SDK will no longer be initialized multiple times - one will be
initialized at application startup and used throughout.

## v2.1.2

- Use v2.1.1 of PHP SDK (https://github.com/ipinfo/php/releases/tag/v2.1.1).
Expand Down
5 changes: 3 additions & 2 deletions src/ipinfolaravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function handle($request, Closure $next)
if ($this->filter && call_user_func($this->filter, $request)) {
$details = null;
} else {
$ipinfo = new IPinfoClient($this->access_token, $this->settings);
$details = $ipinfo->getDetails($request->ip());
$details = $this->ipinfo->getDetails($request->ip());
}

$request->request->set('ipinfo', $details);
Expand All @@ -70,6 +69,8 @@ public function configure()
$ttl = config('services.ipinfo.cache_ttl', self::CACHE_TTL);
$this->settings['cache'] = new DefaultCache($maxsize, $ttl);
}

$this->ipinfo = new IPinfoClient($this->access_token, $this->settings);
}

/**
Expand Down

0 comments on commit 25e5904

Please sign in to comment.