Remove Canapi (#540)

* Remove Canapi

It added more complexity than it helped.

* Fail if there are many blog, but none was specified

* cargo fmt
This commit is contained in:
Baptiste Gelez
2019-04-28 22:17:21 +01:00
committed by GitHub
parent 787eb7f399
commit ec57f1e687
14 changed files with 298 additions and 435 deletions
-1
View File
@@ -4,6 +4,5 @@ version = "0.3.0"
authors = ["Plume contributors"]
[dependencies]
canapi = "0.2"
serde = "1.0"
serde_derive = "1.0"
+2 -9
View File
@@ -1,13 +1,6 @@
use canapi::Endpoint;
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct AppEndpoint {
pub id: Option<i32>,
#[derive(Clone, Serialize, Deserialize)]
pub struct NewAppData {
pub name: String,
pub website: Option<String>,
pub redirect_uri: Option<String>,
pub client_id: Option<String>,
pub client_secret: Option<String>,
}
api!("/api/v1/apps" => AppEndpoint);
-18
View File
@@ -1,24 +1,6 @@
extern crate canapi;
extern crate serde;
#[macro_use]
extern crate serde_derive;
macro_rules! api {
($url:expr => $ep:ty) => {
impl Endpoint for $ep {
type Id = i32;
fn endpoint() -> &'static str {
$url
}
}
};
}
pub mod apps;
pub mod posts;
#[derive(Default)]
pub struct Api {
pub posts: posts::PostEndpoint,
}
+21 -9
View File
@@ -1,13 +1,11 @@
use canapi::Endpoint;
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct PostEndpoint {
pub id: Option<i32>,
pub title: Option<String>,
pub struct NewPostData {
pub title: String,
pub subtitle: Option<String>,
pub content: Option<String>,
pub source: Option<String>,
pub author: Option<String>,
pub source: String,
pub author: String,
// If None, and that there is only one blog, it will be choosen automatically.
// If there are more than one blog, the request will fail.
pub blog_id: Option<i32>,
pub published: Option<bool>,
pub creation_date: Option<String>,
@@ -16,4 +14,18 @@ pub struct PostEndpoint {
pub cover_id: Option<i32>,
}
api!("/api/v1/posts" => PostEndpoint);
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct PostData {
pub id: i32,
pub title: String,
pub subtitle: String,
pub content: String,
pub source: Option<String>,
pub authors: Vec<String>,
pub blog_id: i32,
pub published: bool,
pub creation_date: String,
pub license: String,
pub tags: Vec<String>,
pub cover_id: Option<i32>,
}