-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from kana-rus/impl_response_body_for_iterator_…
…of_response_body_json Support `Option<_>`, `Vec<_>`, `[_; {0-32}]` as JSON `ResponseBody` and `IntoResponse`
- Loading branch information
Showing
13 changed files
with
175 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ edition = "2021" | |
authors = ["kanarus <[email protected]>"] | ||
|
||
[dependencies] | ||
ohkami = { version = "0.14.0", path = "../ohkami", features = ["rt_tokio", "DEBUG"] } | ||
ohkami = { version = "0.15.0", path = "../ohkami", features = ["rt_tokio", "DEBUG"] } | ||
http = "1.0.0" | ||
rustc-hash = "1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "json_response" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["kanarus <[email protected]>"] | ||
|
||
[dependencies] | ||
ohkami = { workspace = true } | ||
tokio = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use ohkami::{typed::ResponseBody, Ohkami, Route}; | ||
|
||
#[ResponseBody(JSONS)] | ||
struct User { | ||
id: u64, | ||
name: String, | ||
} | ||
|
||
async fn single_user() -> User { | ||
User { | ||
id: 42, | ||
name: String::from("ohkami"), | ||
} | ||
} | ||
|
||
async fn multiple_users() -> Vec<User> { | ||
vec![ | ||
User { | ||
id: 42, | ||
name: String::from("ohkami"), | ||
}, | ||
User { | ||
id: 1024, | ||
name: String::from("bynari"), | ||
} | ||
] | ||
} | ||
|
||
async fn nullable_user() -> Option<User> { | ||
None | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
Ohkami::new(( | ||
"/single" .GET(single_user), | ||
"/multiple".GET(multiple_users), | ||
"/nullable".GET(nullable_user), | ||
)).howl("localhost:5000").await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ohkami" | ||
version = "0.14.0" | ||
version = "0.15.0" | ||
edition = "2021" | ||
authors = ["kanarus <[email protected]>"] | ||
description = "Build web app in intuitive and declarative code" | ||
|
@@ -17,7 +17,7 @@ features = ["rt_tokio", "custom-header"] | |
|
||
[dependencies] | ||
ohkami_lib = { version = "=0.1.1", path = "../ohkami_lib" } | ||
ohkami_macros = { version = "=0.5.2", path = "../ohkami_macros" } | ||
ohkami_macros = { version = "=0.6.0", path = "../ohkami_macros" } | ||
tokio = { version = "1", optional = true, features = ["net", "rt", "io-util", "sync"] } | ||
async-std = { version = "1", optional = true } | ||
byte_reader = { version = "2.0.0", features = ["text"] } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
pub mod status; | ||
|
||
mod response_body; | ||
pub use response_body::ResponseBody; | ||
pub use response_body::{ResponseBody, body_type}; | ||
pub use ohkami_macros::ResponseBody; | ||
|
||
pub(crate) mod parse_payload; | ||
#[cfg(test)] mod _test_parse_payload; | ||
pub use parse_payload::{File}; | ||
|
||
pub use ohkami_macros::{Payload, Query}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ proc-macro = true | |
|
||
[package] | ||
name = "ohkami_macros" | ||
version = "0.5.2" | ||
version = "0.6.0" | ||
edition = "2021" | ||
authors = ["kanarus <[email protected]>"] | ||
description = "Proc macros for ohkami - intuitive and declarative web framework" | ||
|
Oops, something went wrong.