Skip to content

Commit 49e9e15

Browse files
committed
Allows rate limit file path override via config variable
Enables customization of the rate limit JSON file location using a configuration variable, improving flexibility for deployments and environments with restrictive filesystem access. Documents the new configuration option in README files for better discoverability.
1 parent 1d063aa commit 49e9e15

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

.openapi-generator/templates/ApiClient.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class ApiClient extends \GuzzleHttp\Client
114114
if (isset($config['rate_limit_store'])) {
115115
$limitStore = $config['rate_limit_store'];
116116
} else {
117-
$path = $config['rate_limit_path'] ?? sys_get_temp_dir().'/rbczpremiumapi_rates.json';
117+
$path = $config['rate_limit_path'] ?? \Ease\Shared::cfg('RBAPI_RATE_LIMIT_JSON_FILE', sys_get_temp_dir().'/rbczpremiumapi_rates.json');
118118
$limitStore = new RateLimit\JsonRateLimitStore($path);
119119
}
120120

.openapi-generator/templates/README.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}).
1414

1515
## Installation & Usage
1616

17-
1817
### Requirements
1918

20-
PHP 7.4 and later.
21-
Should also work with PHP 8.0.
19+
Should with PHP 8+.
2220

2321
### Composer
2422

@@ -60,6 +58,8 @@ XIBMCLIENTID=FbboLD2r1WHDRcuKS4wWUbSRHxlDloWL
6058
API_DEBUG=True
6159
```
6260

61+
Set the `RBAPI_RATE_LIMIT_JSON_FILE` to override default /tmp/rbczpremiumapi_rates.json
62+
6363
Please follow the [installation procedure](#installation--usage) and then run the following:
6464

6565
```php

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ XIBMCLIENTID=FbboLD2r1WHDRcuKS4wWUbSRHxlDloWL
5555
API_DEBUG=True
5656
```
5757

58+
Set the `RBAPI_RATE_LIMIT_JSON_FILE` to override default /tmp/rbczpremiumapi_rates.json
59+
5860
Please follow the [installation procedure](#installation--usage) and then run the following:
5961

6062
```php

lib/ApiClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function __construct(array $config = [])
114114
if (isset($config['rate_limit_store'])) {
115115
$limitStore = $config['rate_limit_store'];
116116
} else {
117-
$path = $config['rate_limit_path'] ?? sys_get_temp_dir().'/rbczpremiumapi_rates.json';
117+
$path = $config['rate_limit_path'] ?? \Ease\Shared::cfg('RBAPI_RATE_LIMIT_JSON_FILE', sys_get_temp_dir().'/rbczpremiumapi_rates.json');
118118
$limitStore = new RateLimit\JsonRateLimitStore($path);
119119
}
120120

0 commit comments

Comments
 (0)