cloudflare/framework/
endpoint.rs1use crate::framework::ApiResultTraits;
2use crate::framework::Environment;
3use serde::Serialize;
4use url::Url;
5
6pub trait Endpoint<ResultType = (), QueryType = (), BodyType = ()>
7where
8 ResultType: ApiResultTraits,
9 QueryType: Serialize,
10 BodyType: Serialize,
11{
12 fn method(&self) -> surf::http::Method;
13 fn path(&self) -> String;
14 fn query(&self) -> Option<QueryType> {
15 None
16 }
17 fn body(&self) -> Option<BodyType> {
18 None
19 }
20 fn url(&self, environment: &Environment) -> Url {
21 Url::from(environment).join(&self.path()).unwrap()
22 }
23 fn content_type(&self) -> String {
24 "application/json".to_owned()
25 }
26}