Last active
March 16, 2017 11:33
-
-
Save goyox86/ac18acfe7c5b3e999a4f07d32c71c896 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 user = diesel::insert(&new_user.0).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