cloudflare/endpoints/workers/
create_route.rs1use surf::http::Method;
2
3use super::WorkersRouteIdOnly;
4use crate::framework::endpoint::Endpoint;
5
6#[derive(Debug)]
10pub struct CreateRoute<'a> {
11 pub zone_identifier: &'a str,
12 pub params: CreateRouteParams,
13}
14
15impl<'a> Endpoint<WorkersRouteIdOnly, (), CreateRouteParams> for CreateRoute<'a> {
16 fn method(&self) -> Method {
17 Method::Post
18 }
19 fn path(&self) -> String {
20 format!("zones/{}/workers/routes", self.zone_identifier)
21 }
22 fn body(&self) -> Option<CreateRouteParams> {
23 Some(self.params.clone())
24 }
25}
26
27#[derive(Serialize, Clone, Debug)]
32pub struct CreateRouteParams {
33 pub pattern: String,
34 pub script: Option<String>,
35}