cloudflare_but_works/endpoints/workers/
create_route.rs1use super::WorkersRouteIdOnly;
2
3use crate::framework::endpoint::{EndpointSpec, Method, RequestBody};
4
5use crate::framework::response::ApiSuccess;
6use serde::Serialize;
7
8#[derive(Debug)]
12pub struct CreateRoute<'a> {
13 pub zone_identifier: &'a str,
14 pub params: CreateRouteParams,
15}
16
17impl EndpointSpec for CreateRoute<'_> {
18 type JsonResponse = WorkersRouteIdOnly;
19 type ResponseType = ApiSuccess<Self::JsonResponse>;
20
21 fn method(&self) -> Method {
22 Method::POST
23 }
24 fn path(&self) -> String {
25 format!("zones/{}/workers/routes", self.zone_identifier)
26 }
27 #[inline]
28 fn body(&self) -> Option<RequestBody> {
29 let body = serde_json::to_string(&self.params).unwrap();
30 Some(RequestBody::Json(body))
31 }
32}
33
34#[derive(Serialize, Clone, Debug)]
39pub struct CreateRouteParams {
40 pub pattern: String,
41 pub script: Option<String>,
42}