diff options
| author | Gus Power <gus@infinitesidequests.com> | 2025-05-22 16:21:05 +0100 |
|---|---|---|
| committer | Gus Power <gus@infinitesidequests.com> | 2025-05-22 16:21:05 +0100 |
| commit | 3e5aa28345bb009c12b5a55f2e7174957bf4ed9a (patch) | |
| tree | fa9044d9e72e213aed22d1761a2bf01a439a0550 /src/ip_service.rs | |
| parent | e417f3afd13fa770a3b64d604bb1686ed6a77203 (diff) | |
started on arbitrary http endpoint configuration
Diffstat (limited to 'src/ip_service.rs')
| -rw-r--r-- | src/ip_service.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ip_service.rs b/src/ip_service.rs index 3d869db..abe75f1 100644 --- a/src/ip_service.rs +++ b/src/ip_service.rs @@ -1,5 +1,5 @@ use crate::error::{AppError, AppResult}; -use crate::ip_service::IpServiceProvider::{IdentMe, Noop}; +use crate::ip_service::IpServiceProvider::{Http, IdentMe, Noop}; use http::StatusCode; use reqwest::{Client, Url}; use serde::{Deserialize, Serialize}; @@ -11,15 +11,21 @@ use std::str::FromStr; #[derive(Debug, Deserialize, PartialEq, Serialize)] #[serde(tag = "type")] pub enum IpServiceProvider { + #[serde(rename = "HTTP")] + Http(HttpConfig), #[serde(rename = "IDENTME")] IdentMe(IdentMeConfig), #[serde(rename = "NOOP")] Noop, } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct HttpConfig; + impl IpService for IpServiceProvider { async fn resolve(&self, client: &Client) -> AppResult<IpAddr> { match self { + Http(_http) => Ok(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), IdentMe(ident_me) => ident_me.resolve(client).await, Noop => Ok(IpAddr::V4(Ipv4Addr::UNSPECIFIED)), } @@ -84,6 +90,9 @@ impl Default for IdentMeConfig { } } +// http service +// url - method - headers - response content-type (text, json) - response parser (text, json -> json path?) + impl IpService for IdentMeConfig { async fn resolve(&self, client: &Client) -> AppResult<IpAddr> { let response = client |
