mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 23:30:35 -04:00
Use HTTP code enums instead of ints
This commit is contained in:
parent
3f822b85c3
commit
3050ab7219
28 changed files with 56 additions and 56 deletions
|
@ -131,11 +131,11 @@ try{
|
|||
}
|
||||
|
||||
// "Success, no content"
|
||||
http_response_code(204);
|
||||
http_response_code(Enums\HttpCode::NoContent->value);
|
||||
}
|
||||
catch(Exceptions\InvalidCredentialsException){
|
||||
// "Forbidden"
|
||||
http_response_code(403);
|
||||
http_response_code(Enums\HttpCode::Forbidden->value);
|
||||
}
|
||||
catch(Exceptions\WebhookException $ex){
|
||||
// Uh oh, something went wrong!
|
||||
|
@ -147,13 +147,13 @@ catch(Exceptions\WebhookException $ex){
|
|||
print($ex->getMessage());
|
||||
|
||||
// "Client error"
|
||||
http_response_code(400);
|
||||
http_response_code(Enums\HttpCode::BadRequest->value);
|
||||
}
|
||||
catch(Exceptions\NoopException){
|
||||
// We arrive here because a special case required us to take no action for the request, but execution also had to be interrupted.
|
||||
// For example, we received a request for a known repo for which we must ignore requests.
|
||||
|
||||
// "Success, no content"
|
||||
http_response_code(204);
|
||||
http_response_code(Enums\HttpCode::NoContent->value);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -74,12 +74,12 @@ try{
|
|||
$log->Write('Event processed.');
|
||||
|
||||
// "Success, no content"
|
||||
http_response_code(204);
|
||||
http_response_code(Enums\HttpCode::NoContent->value);
|
||||
}
|
||||
catch(Exceptions\InvalidCredentialsException){
|
||||
// "Forbidden"
|
||||
$log->Write('Invalid key: ' . ($_SERVER['HTTP_X_SE_KEY'] ?? ''));
|
||||
http_response_code(403);
|
||||
http_response_code(Enums\HttpCode::Forbidden->value);
|
||||
}
|
||||
catch(Exceptions\WebhookException $ex){
|
||||
// Uh oh, something went wrong!
|
||||
|
@ -91,5 +91,5 @@ catch(Exceptions\WebhookException $ex){
|
|||
print($ex->getMessage());
|
||||
|
||||
// "Client error"
|
||||
http_response_code(400);
|
||||
http_response_code(Enums\HttpCode::BadRequest->value);
|
||||
}
|
||||
|
|
|
@ -51,12 +51,12 @@ try{
|
|||
$log->Write('Event processed.');
|
||||
|
||||
// "Success, no content"
|
||||
http_response_code(204);
|
||||
http_response_code(Enums\HttpCode::NoContent->value);
|
||||
}
|
||||
catch(Exceptions\InvalidCredentialsException){
|
||||
// "Forbidden"
|
||||
$log->Write('Couldn\'t validate POST data.');
|
||||
http_response_code(403);
|
||||
http_response_code(Enums\HttpCode::Forbidden->value);
|
||||
}
|
||||
catch(Exceptions\WebhookException $ex){
|
||||
// Uh oh, something went wrong!
|
||||
|
@ -68,5 +68,5 @@ catch(Exceptions\WebhookException $ex){
|
|||
print($ex->getMessage());
|
||||
|
||||
// "Client error"
|
||||
http_response_code(400);
|
||||
http_response_code(Enums\HttpCode::BadRequest->value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue