Add canapi and try to use for the API

This commit is contained in:
Bat
2018-09-19 15:49:34 +01:00
parent eb24ba1774
commit 1500267125
16 changed files with 211 additions and 10 deletions
+1
View File
@@ -0,0 +1 @@
pub mod posts;
+11
View File
@@ -0,0 +1,11 @@
use rocket_contrib::Json;
use serde_json;
use plume_models::db_conn::DbConn;
use plume_models::posts::Post;
#[get("/posts/<id>")]
fn get(id: i32, conn: DbConn) -> Json<serde_json::Value> {
let post = Post::get(&*conn, id).unwrap();
Json(post.to_json(&*conn))
}