mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 09:11:11 +00:00
Finish API documentation and token auth (references #5)
This commit is contained in:
@@ -4,8 +4,16 @@ namespace Grocy\Helpers;
|
||||
|
||||
class UrlManager
|
||||
{
|
||||
public function __construct(string $basePath) {
|
||||
$this->BasePath = $basePath;
|
||||
public function __construct(string $basePath)
|
||||
{
|
||||
if ($basePath === '/')
|
||||
{
|
||||
$this->BasePath = $this->GetBaseUrl();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->BasePath = $basePath;
|
||||
}
|
||||
}
|
||||
|
||||
protected $BasePath;
|
||||
@@ -14,4 +22,9 @@ class UrlManager
|
||||
{
|
||||
return rtrim($this->BasePath, '/') . $relativePath;
|
||||
}
|
||||
|
||||
private function GetBaseUrl()
|
||||
{
|
||||
return (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user