-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
456a731
commit f891d71
Showing
8 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
pub mod user_api; |
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,17 @@ | ||
use crate::dto::user_dto_request::UserDtoRequest; | ||
use rocket::serde::json::Json; | ||
use rocket::{get, Build, Rocket}; | ||
|
||
#[get("/")] | ||
pub fn index() -> &'static str { | ||
"Hello, world!" | ||
} | ||
|
||
#[post("/user", format = "application/json", data = "<user_dto_request>")] | ||
async fn post_user(user_dto_request: Json<UserDtoRequest>) { | ||
println!("User name : {}", user_dto_request.name) | ||
} | ||
|
||
pub fn build_api() -> Rocket<Build> { | ||
rocket::build().mount("/", routes![index]).mount("/api/v1/", routes![post_user]) | ||
} |
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 @@ | ||
pub mod user_dto_request; |
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,7 @@ | ||
use rocket::serde::Deserialize; | ||
|
||
#[derive(Deserialize)] | ||
#[serde(crate = "rocket::serde")] | ||
pub struct UserDtoRequest { | ||
pub name: String, | ||
} |
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,12 +1,5 @@ | ||
#[macro_use] | ||
pub extern crate rocket; | ||
use rocket::{get, Build, Rocket}; | ||
|
||
#[get("/")] | ||
pub fn index() -> &'static str { | ||
"Hello, world!" | ||
} | ||
|
||
pub fn build_api() -> Rocket<Build> { | ||
rocket::build().mount("/", routes![index]) | ||
} | ||
pub mod api; | ||
pub mod dto; |
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