kepsondiaz / httpjsonbridge
An elegant json response for your laravel api
1.0.0
2024-09-06 11:47 UTC
Requires (Dev)
- orchestra/testbench: ^9.4
README
A simple way to define your Json Response for your Laravel's Api .
installation
composer require kepsondiaz/httpjsonbridge
Doc
Send a response based on the event that occurs when your api is called
send a Response when a badRequest occur. Status code 400
/** * Response with status code 400. */ return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->badRequestApiResponse([ 'message' => 'your custom message for response' ]);
send a Response when response is OK.
/** * Response with status code 200. */ return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->okApiResponse([ // do something ]);
send a Response when response when resource is not found
/** * Response with status code 404. */ return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->notFoundApiResponse([ // do something ]);
send a Response when response when user is unauthorised
/** * Response with status code 401. */ return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->unauthorizedApiResponse([ // do something ]);