mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(blog::api) pagination
This commit is contained in:
13 files changed
+83
-168
No files matched your search
@@ -0,0 +1,31 @@
|
||||
use axum::{
|
||||
http::{StatusCode, header::CONTENT_TYPE},
|
||||
response::Response,
|
||||
};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
pub fn err_resp(code: StatusCode, err_msg: String) -> Response<String> {
|
||||
let payload = json!({
|
||||
"status": "error",
|
||||
"data": {
|
||||
"msg": err_msg,
|
||||
}
|
||||
});
|
||||
resp_json(code, payload)
|
||||
}
|
||||
|
||||
pub fn succ_resp(code: StatusCode, payload: Value) -> Response<String> {
|
||||
let payload = json!({
|
||||
"status": "success",
|
||||
"data": payload
|
||||
});
|
||||
resp_json(code, payload)
|
||||
}
|
||||
|
||||
pub fn resp_json(code: StatusCode, payload: Value) -> Response<String> {
|
||||
Response::builder()
|
||||
.status(code)
|
||||
.header(CONTENT_TYPE, "application/json")
|
||||
.body(payload.to_string())
|
||||
.unwrap()
|
||||
}
|
||||
Reference in new issue
Block a user