Add canapi and try to use for the API
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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 posts;
|
||||
@@ -0,0 +1,11 @@
|
||||
use canapi::Endpoint;
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct PostEndpoint {
|
||||
pub id: Option<i32>,
|
||||
pub title: Option<String>,
|
||||
pub subtitle: Option<String>,
|
||||
pub content: Option<String>
|
||||
}
|
||||
|
||||
api!("/api/v1/posts" => PostEndpoint);
|
||||
Reference in New Issue
Block a user