cloudflare/endpoints/argo_tunnel/
route_dns.rs

1use surf::http::Method;
2use uuid::Uuid;
3
4use super::RouteResult;
5use crate::framework::endpoint::Endpoint;
6
7/// Route for a Named Argo Tunnel
8/// This creates a new route for the identified Tunnel. More than 1 route may co-exist for the same
9/// Tunnel.
10/// Note that this modifies only metadata on Cloudflare side to route traffic to the Tunnel, but
11/// it is still up to the user to run the Tunnel to receive that traffic.
12#[derive(Debug)]
13pub struct RouteTunnel<'a> {
14    pub zone_tag: &'a str,
15    pub tunnel_id: Uuid,
16    pub params: Params<'a>,
17}
18
19impl<'a> Endpoint<RouteResult, (), Params<'a>> for RouteTunnel<'a> {
20    fn method(&self) -> Method {
21        Method::Put
22    }
23    fn path(&self) -> String {
24        format!("zones/{}/tunnels/{}/routes", self.zone_tag, self.tunnel_id)
25    }
26    fn body(&self) -> Option<Params<'a>> {
27        Some(self.params.clone())
28    }
29}
30
31/// Params for routing a Named Argo Tunnel
32#[derive(Serialize, Clone, Debug)]
33#[serde(tag = "type", rename_all = "lowercase")]
34pub enum Params<'a> {
35    Dns { user_hostname: &'a str },
36    Lb { lb_name: &'a str, lb_pool: &'a str },
37}