From 828969d73e0261b7348af7a842851a89a780ddf4 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 17 May 2018 00:09:57 -0700 Subject: editgroup post --- rust/src/api_server.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'rust/src') diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index 52e9501f..2a744525 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -626,14 +626,27 @@ impl Api for Server { fn editgroup_post( &self, + body: models::Editgroup, context: &Context, ) -> Box + Send> { - let context = context.clone(); - println!( - "editgroup_post() - X-Span-ID: {:?}", - context.x_span_id.unwrap_or(String::from("")).clone() - ); - Box::new(futures::failed("Generic failure".into())) + let conn = self.db_pool.get().expect("db_pool error"); + + let row: EditgroupRow = insert_into(editgroup::table) + .values(( + editgroup::editor_id.eq(body.editor_id as i64), + editgroup::description.eq(body.description) + )) + .get_result(&conn) + .expect("error creating edit group"); + + let new_eg = Editgroup { + id: Some(row.id as isize), + editor_id: row.editor_id as isize, + description: row.description, + }; + Box::new(futures::done(Ok(EditgroupPostResponse::SuccessfullyCreated( + new_eg, + )))) } fn editor_username_changelog_get( -- cgit v1.2.3