Skip to content

Commit

Permalink
Merge pull request #10 from MRizki28/1.x
Browse files Browse the repository at this point in the history
feat(response): add new response for unauthorize
  • Loading branch information
MRizki28 authored Oct 26, 2024
2 parents d909d6b + e303b9c commit 0bb3c03
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ApiResponse/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,22 @@ public static function error(\Throwable $th = null, $message = 'Error', int $cod
['Content-Type' => 'application/json']
);
}

/**
* Format an unauthorized response.
*
* @return string JSON formatted response.
*/

public static function unauthorized()
{
return new Response(
json_encode([
'status' => 'Unauthorized',
'message' => 'Unauthorized'
]),
401,
['Content-Type' => 'application/json']
);
}
}

0 comments on commit 0bb3c03

Please sign in to comment.