Amber
2 years ago
3 changed files with 50 additions and 24 deletions
@ -1,11 +1,34 @@
@@ -1,11 +1,34 @@
|
||||
use axum::{routing::{post, get}, Router}; |
||||
use axum::{ |
||||
extract::{Path, State}, |
||||
response::{Html, IntoResponse}, |
||||
routing::{get, post}, |
||||
Router, |
||||
}; |
||||
|
||||
pub(crate) fn routes() -> Router { |
||||
Router::new() |
||||
.route("/text", post(todo!())) |
||||
.route("/file", post(todo!())) |
||||
.route("/link", post(todo!())) |
||||
.route("/text/:id", get(todo!()).post(todo!())) |
||||
.route("/file/:id", get(todo!()).post(todo!())) |
||||
.route("/link/:id", get(todo!()).post(todo!())) |
||||
use crate::{data::TextMeta, AppState, Error}; |
||||
|
||||
pub(crate) fn routes() -> Router<AppState> { |
||||
Router::new().route("/text", post(post_text)) |
||||
/*Router::new()
|
||||
.route("/text", post(todo!())) |
||||
.route("/file", post(todo!())) |
||||
.route("/link", post(todo!())) |
||||
.route("/text/:id", get(todo!()).post(todo!())) |
||||
.route("/file/:id", get(todo!()).post(todo!())) |
||||
.route("/link/:id", get(todo!()).post(todo!()))*/ |
||||
} |
||||
|
||||
async fn post_text(State(state): State<AppState>, body: String) -> impl IntoResponse { |
||||
println!("post {}", body); |
||||
state |
||||
.cache |
||||
.write() |
||||
.unwrap() |
||||
.create_text( |
||||
"yea".to_string(), |
||||
"meoww :3".to_string(), |
||||
TextMeta::parse("language: catperson").unwrap(), |
||||
) |
||||
.unwrap(); |
||||
return "a".into_response(); |
||||
} |
||||
|
Loading…
Reference in new issue