-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New endpoint for routing Named Argo Tunnels (#131)
- Loading branch information
1 parent
37d52e1
commit 53a5b62
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod create_tunnel; | ||
mod data_structures; | ||
pub mod route_dns; | ||
|
||
pub use data_structures::*; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::framework::endpoint::{Endpoint, Method}; | ||
|
||
use super::RouteResult; | ||
use uuid::Uuid; | ||
|
||
/// Route for a Named Argo Tunnel | ||
/// This creates a new route for the identified Tunnel. More than 1 route may co-exist for the same | ||
/// Tunnel. | ||
/// Note that this modifies only metadata on Cloudflare side to route traffic to the Tunnel, but | ||
/// it is still up to the user to run the Tunnel to receive that traffic. | ||
pub struct RouteTunnel<'a> { | ||
pub zone_tag: &'a str, | ||
pub tunnel_id: Uuid, | ||
pub params: Params<'a>, | ||
} | ||
|
||
impl<'a> Endpoint<RouteResult, (), Params<'a>> for RouteTunnel<'a> { | ||
fn method(&self) -> Method { | ||
Method::Put | ||
} | ||
fn path(&self) -> String { | ||
format!("zones/{}/tunnels/{}/routes", self.zone_tag, self.tunnel_id) | ||
} | ||
fn body(&self) -> Option<Params<'a>> { | ||
Some(self.params.clone()) | ||
} | ||
} | ||
|
||
/// Params for routing a Named Argo Tunnel | ||
#[derive(Serialize, Clone, Debug)] | ||
#[serde(tag = "type", rename_all = "lowercase")] | ||
pub enum Params<'a> { | ||
Dns { user_hostname: &'a str }, | ||
Lb { lb_name: &'a str, lb_pool: &'a str }, | ||
} |