mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Fix oxidized web requests not closing connections or responding fast enough * Update showconfig.inc.php * Add method to get the text content of an oxidized page * Use Oxidized getContent method instead of file_get_content * Too much brackets with copy paste * Fix carriage return errors because of copy paste * Fix copy paste error again * Fix indent * PHPStan is waiting for a return even outside of the if loop * Single quotes * Variabilize timeout in baseapi * Set Oxidized Api class timeout var to 90 because oxidized is slow and to be sure not to break half the installs here * fix typo * Variabilize timeout * Variabilize timeout * Variabilize timeout * Variabilize timeout * Variabilize timeout * Spacing * Remove timeout type because of this error Unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in app/ApiClients/BaseApi.php on line 34 * Lint needs type finally * Use contruct instead of setting variable * Type hinting instead for php7.3 * Type hinting fix * Set property value instead of calling parent constructor * Typo * Remove unneededconstructors * Remove unneeded constructors * Remove unneeded constructors * Remove unneeded constructors * Remove unneeded constructors * Remove unneeded constructors * Typing not casting * Typing not casting * Cannot type variables outside of a class Co-authored-by: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com>
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* BaseApi.php
|
|
*
|
|
* -Description-
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* @link https://www.librenms.org
|
|
*
|
|
* @copyright 2018 Tony Murray
|
|
* @author Tony Murray <murraytony@gmail.com>
|
|
*/
|
|
|
|
namespace App\ApiClients;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
use LibreNMS\Util\Proxy;
|
|
|
|
class BaseApi
|
|
{
|
|
protected $base_uri;
|
|
/** @var int */
|
|
protected $timeout = 3;
|
|
private $client;
|
|
|
|
protected function getClient(): \Illuminate\Http\Client\PendingRequest
|
|
{
|
|
if (is_null($this->client)) {
|
|
$this->client = Http::withOptions([
|
|
'proxy' => Proxy::forGuzzle($this->base_uri),
|
|
])->baseUrl($this->base_uri)
|
|
->timeout($this->timeout);
|
|
}
|
|
|
|
return $this->client;
|
|
}
|
|
}
|