added serde dep; added questions.rs
This commit is contained in:
parent
88f4dd6bd6
commit
c62357fd3e
9
Cargo.lock
generated
9
Cargo.lock
generated
@ -733,6 +733,7 @@ name = "rust-web"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"serde",
|
||||
"tokio",
|
||||
"warp",
|
||||
]
|
||||
@ -769,18 +770,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.197"
|
||||
version = "1.0.198"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||
checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.197"
|
||||
version = "1.0.198"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||
checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -7,5 +7,6 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
axum = "0.7.5"
|
||||
serde = "1.0.198"
|
||||
tokio = { version = "1.2", features = ["full"] }
|
||||
warp = "0.3.7"
|
||||
|
25
src/question.rs
Normal file
25
src/question.rs
Normal file
@ -0,0 +1,25 @@
|
||||
struct Question {
|
||||
id: QuestionId,
|
||||
title: String,
|
||||
content: String,
|
||||
tags: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
struct QuestionId(String);
|
||||
|
||||
impl Question{
|
||||
fn new(id: QuestionId, title: String, content: String, tags: Option<Vec<String>>) -> Self {
|
||||
Question {
|
||||
id,
|
||||
title,
|
||||
content,
|
||||
tags,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoResponse for &Question {
|
||||
fn into_response(self) -> Response {
|
||||
(StatusCode::OK, Json(&self)).into_response()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user