diff --git a/src/main.rs b/src/main.rs index 07813dd..e691bca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ struct Config { /// Token to match the one provided by the Webhook service #[serde(rename = "webhook-token")] - webhook_token: Option, + webhook_token: String, /// HTTP Webhook listening address and port, e.g., 127.0.0.1:1234 or [::1]:1234 #[serde(default = "default_addr")] @@ -140,8 +140,8 @@ async fn main() -> Result { ); let tcp_bind = TcpListener::bind(config.addr).await?; - let token: Option<&'static String> = - unsafe { core::mem::transmute(config.webhook_token.as_ref()) }; + let token: &'static String = + unsafe { core::mem::transmute::<&String, &'static String>(&config.webhook_token) }; let value_tx = Arc::new(Mutex::new(value_tx)); loop { diff --git a/src/web.rs b/src/web.rs index 0892754..a4d4add 100644 --- a/src/web.rs +++ b/src/web.rs @@ -36,7 +36,7 @@ fn error_res(e: E) -> Result>, Infallib Ok(res) } -async fn webhooks_inner(req: Request, token: Option<&String>) -> Result { +async fn webhooks_inner(req: Request, token: &str) -> Result { match req.method() { &Method::POST => (), _ => return Err(Error::MethodMismatch), @@ -64,7 +64,7 @@ async fn webhooks_inner(req: Request, token: Option<&String>) -> Resul pub async fn webhooks( req: Request, - token: Option<&String>, + token: &str, value_tx: Arc>>, ) -> Result>, Infallible> { match webhooks_inner(req, token).await {