Plume/src/api/apps.rs

13 lines
390 B
Rust
Raw Normal View History

2018-10-21 18:22:27 +02:00
use canapi::Provider;
use rocket_contrib::json::Json;
2018-10-21 18:22:27 +02:00
use serde_json;
use plume_api::apps::AppEndpoint;
2019-03-20 17:56:17 +01:00
use plume_models::{apps::App, db_conn::DbConn, Connection};
2018-10-21 18:22:27 +02:00
#[post("/apps", data = "<data>")]
pub fn create(conn: DbConn, data: Json<AppEndpoint>) -> Json<serde_json::Value> {
2018-10-21 18:22:27 +02:00
let post = <App as Provider<Connection>>::create(&*conn, (*data).clone()).ok();
Json(json!(post))
}