mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(api) add refresh.rs
This commit is contained in:
10 files changed
+127
-9
No files matched your search
@@ -0,0 +1,12 @@
|
||||
use axum::extract::{Path, State};
|
||||
use axum::Json;
|
||||
use serde_json::Value;
|
||||
use sqlx::PgPool;
|
||||
|
||||
pub async fn get_post(
|
||||
State(_db_connection): State<PgPool>,
|
||||
Path(post_id): Path<String>,
|
||||
) -> Result<Json<Value>, Json<Value>> {
|
||||
dbg!(&post_id);
|
||||
todo!()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
use axum::extract::State;
|
||||
use axum::Json;
|
||||
use serde_json::Value;
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::model::Post;
|
||||
|
||||
pub async fn get_post_list(
|
||||
State(db_connection): State<PgPool>,
|
||||
Json(_request): Json<Value>,
|
||||
) -> Result<Json<Value>, Json<Value>> {
|
||||
let post_list: Vec<Post> = sqlx::query_as("select * from post")
|
||||
.fetch_all(&db_connection)
|
||||
.await
|
||||
.unwrap();
|
||||
dbg!(&post_list);
|
||||
Ok(Json::from(serde_json::to_value(post_list).unwrap()))
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod get_post;
|
||||
pub mod get_post_list;
|
||||
Reference in new issue
Block a user