use canapi::Provider; use diesel::PgConnection; use rocket_contrib::Json; use serde_json; use plume_api::posts::PostEndpoint; use plume_models::db_conn::DbConn; use plume_models::posts::Post; #[get("/posts/")] fn get(id: i32, conn: DbConn) -> Json { let post = >::get(&*conn, id).ok(); Json(json!(post)) } // TODO: handle query params #[get("/posts")] fn list(conn: DbConn) -> Json { let post = >::list(&*conn, PostEndpoint::default()); Json(json!(post)) }