Skip to content

Restore httpStatusCodetoString #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions application/controllers/IcingadbimgController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
class IcingadbimgController extends IcingadbGrafanaController
{
protected $host;
protected $service;
protected $timerange;
protected $myConfig;
protected $myAuth;
Expand Down
55 changes: 55 additions & 0 deletions library/Grafana/Helpers/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,59 @@ public static function getUserThemeMode(User $user): string

return $mode;
}

/**
* httpStatusCodetoString translates a HTTP status code to a readable message
*
* @param int $code HTTP status code
* @return string
*/
public static function httpStatusCodetoString(int $code = 0): string
{
$statuscodes = [
'100' => 'Continue',
'101' => 'Switching Protocols',
'200' => 'OK',
'201' => 'Created',
'202' => 'Accepted',
'203' => 'Non-Authoritative Information',
'204' => 'No Content',
'205' => 'Reset Content',
'206' => 'Partial Content',
'300' => 'Multiple Choices',
'302' => 'Found',
'303' => 'See Other',
'304' => 'Not Modified',
'305' => 'Use Proxy',
'400' => 'Bad Request',
'401' => 'Unauthorized',
'402' => 'Payment Required',
'403' => 'Forbidden',
'404' => 'Not Found',
'405' => 'Method Not Allowed',
'406' => 'Not Acceptable',
'407' => 'Proxy Authentication Required',
'408' => 'Request Timeout',
'409' => 'Conflict',
'410' => 'Gone',
'411' => 'Length Required',
'412' => 'Precondition Failed',
'413' => 'Request Entity Too Large',
'414' => 'Request-URI Too Long',
'415' => 'Unsupported Media Type',
'416' => 'Requested Range Not Satisfiable',
'417' => 'Expectation Failed',
'500' => 'Internal Server Error',
'501' => 'Not Implemented',
'502' => 'Bad Gateway',
'503' => 'Service Unavailable',
'504' => 'Gateway Timeout',
'505' => 'HTTP Version Not Supported'
];
$code = (string)$code;
if (array_key_exists($code, $statuscodes)) {
return $statuscodes[$code];
}
return $code;
}
}