cerenimo/response-messages
Composer 安装命令:
composer require cerenimo/response-messages
包简介
README 文档
README
composer require cerenimo/response-messages "dev-main"
The ResponseTrait is a trait used to standardize the HTTP response messages in Laravel and Lumen. You can install it using the composer command mentioned above. To use it in your class, add the following line with the "use" keyword:
use CerenOzkurt\ResponseMessages\ResponseTrait; class YourClass { use ResponseTrait; // ... }
Inside your function, you can use it as follows:
return $this->responseData(['message' => $message]);
Response / 200 OK
{
"result": true,
"data": {
"message": {
"id": 372,
"role": "user",
"message": "Hi",
"end_conversation": 0,
"created_time": "2023-05-30T09:28:01.000000Z",
"conversation_completion_count": "0.60",
"word_count": 1
}
}
}
The package provides the following functions:
-
responseData($data, $message = null) : Use if the request is successful and data is wanted to be returned.
-
responseSuccess($message = null) : Use if the request is successful.
-
responseError($message = null, $status = 500) : Use if the request is error.
-
responseValidation($validation) : Use if there is a validation error.
-
responseDataNotFound($data_name = null) : Use if not found error.
-
responseForbidden($message = null) : Use in forbidden error.
-
responseUnauthorized($message = null) : Use in unauthorized error.
-
responseTryCatch($message = null, $status = 500) : Use in try-catch error.
-
responseDataCount($data) : Use if the data need count information.
-
responseBadRequest($message = null) : Use if the sent request is incorrect.
-
responseConflict($message = null) : Use if a mismatch occurs due to a predetermined rule or version differences on the web server of your request.
-
responsePayloadTooLarge($message = null) : Use if the request entity is much larger than the limits defined by the server.
-
responseTooManyRequests($message = null) : Use if the website exceeded the specified request limit.
-
responseInternalServer($message = null) : Use if a server-side error occurred.
-
responseNotImplemented($message = null) : Use if the server does not support the features required to fulfill the request.
统计信息
- 总下载量: 1.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-01