Created
March 16, 2017 11:39
-
-
Save goyox86/bf192c17cf578856ffdef07e3bf30069 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#[post("/users", data = "<new_user>", format = "application/json")] | |
fn create(db: State<Db>, new_user: JSON<NewUser>) -> EndpointResult<JSON<User>> { | |
let conn = &*db.pool().get()?; | |
let new_user = NewUserReadyForInsertion::from(new_user.0); | |
let user = diesel::insert(&new_user).into(users::table) | |
.get_result::<User>(conn)?; | |
Ok(JSON(user)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment