http_api_util 0.1.2

abstract trait for web api
Documentation
use serde::{Serialize, Deserialize};
pub mod cache;
pub trait Api {
    type Request: Serialize;
    type Response: for <'a> Deserialize<'a>;
    const METHOD: http::Method;
    const CONST_URL: Option<&'static str> = None;
    fn dynamic_url(_request: &Self::Request) -> http::Uri {
        return http::Uri::from_static(Self::CONST_URL.unwrap_or_default());
    }
    fn url(_request: &Self::Request) -> http::Uri {
        if let Some(const_url) = Self::CONST_URL {
            return http::Uri::from_static(const_url)
        } else {
            return Self::dynamic_url(_request)
        }
    }
}