cloudflare_but_works/endpoints/workers/
create_tail.rs1use super::WorkersTail;
2
3use crate::framework::endpoint::{EndpointSpec, Method, RequestBody};
4
5use crate::framework::response::ApiSuccess;
6use serde::Serialize;
7
8#[derive(Debug)]
11pub struct CreateTail<'a> {
12 pub account_identifier: &'a str,
14 pub script_name: &'a str,
16 pub params: CreateTailParams,
22}
23
24impl EndpointSpec for CreateTail<'_> {
25 type JsonResponse = WorkersTail;
26 type ResponseType = ApiSuccess<Self::JsonResponse>;
27
28 fn method(&self) -> Method {
29 Method::POST
30 }
31 fn path(&self) -> String {
32 format!(
33 "accounts/{}/workers/scripts/{}/tails",
34 self.account_identifier, self.script_name
35 )
36 }
37 #[inline]
38 fn body(&self) -> Option<RequestBody> {
39 if self.params.url.is_some() {
40 let body = serde_json::to_string(&self.params).unwrap();
41 Some(RequestBody::Json(body))
42 } else {
43 None
44 }
45 }
46}
47
48#[derive(Serialize, Clone, Debug, Default)]
49pub struct CreateTailParams {
50 pub url: Option<String>,
52}