diff --git a/proxy/src/proxy.rs b/proxy/src/proxy.rs index 772eb80..d165029 100644 --- a/proxy/src/proxy.rs +++ b/proxy/src/proxy.rs @@ -116,15 +116,12 @@ impl ProxyHttp for KupoProxy { .get_header("host") .map(|v| v.to_str().unwrap()) .unwrap(); - let captures = self.host_regex.captures(host).unwrap(); - let mut key = session + let key = session .get_header(DMTR_API_KEY) - .map(|v| v.to_str().unwrap()) + .and_then(|v| v.to_str().ok()) + .or_else(|| captures.get(1).map(|v| v.as_str())) .unwrap_or_default(); - if let Some(m) = captures.get(1) { - key = m.as_str(); - } let consumer = state.get_consumer(key).await; if consumer.is_none() {