From adfc678a8a556ea72c3602d14dcc500d2bfa2d0f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 26 Aug 2020 17:35:18 -0700 Subject: more endpoints/methods --- src/lib.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 75afbc5..652e6be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -78,27 +78,40 @@ pub async fn filter_request( // this is sort of like a router let body = match (&parts.method, path_chunks.as_slice()) { - (&Method::GET, [""]) | (&Method::HEAD, [""]) => Body::empty(), + (&Method::GET, [""]) | (&Method::HEAD, [""]) | (&Method::OPTIONS, [""]) => Body::empty(), + (&Method::HEAD, ["_search", "scroll"]) | (&Method::OPTIONS, ["_search", "scroll"]) => Body::empty(), (&Method::POST, ["_search", "scroll"]) | (&Method::DELETE, ["_search", "scroll"]) => { let whole_body = hyper::body::to_bytes(body) .await .map_err(|e| ProxyError::Malformed(e.to_string()))?; filter_scroll_request(¶ms, &whole_body, config)? } + (&Method::HEAD, [index, "_search"]) | (&Method::OPTIONS, [index, "_search"]) => { + filter_search_request(index, ¶ms, &[], config)? + } (&Method::GET, [index, "_search"]) | (&Method::POST, [index, "_search"]) => { let whole_body = hyper::body::to_bytes(body) .await .map_err(|e| ProxyError::Malformed(e.to_string()))?; filter_search_request(index, ¶ms, &whole_body, config)? } + (&Method::HEAD, [index, "_count"]) | (&Method::OPTIONS, [index, "_count"]) => { + filter_search_request(index, ¶ms, &[], config)? + } (&Method::GET, [index, "_count"]) | (&Method::POST, [index, "_count"]) => { let whole_body = hyper::body::to_bytes(body) .await .map_err(|e| ProxyError::Malformed(e.to_string()))?; filter_search_request(index, ¶ms, &whole_body, config)? } - (&Method::GET, [index, "_doc", key]) | (&Method::GET, [index, "_source", key]) => { - filter_read_request(index, path_chunks[1], key, ¶ms, config)? + (&Method::GET, [index, "_doc", _key]) | (&Method::GET, [index, "_source", _key]) | (&Method::HEAD, [index, "_doc", _key]) | (&Method::OPTIONS, [index, "_source", _key]) => { + filter_read_request(index, path_chunks[1], ¶ms, config)? + } + (&Method::GET, [index, ""]) | (&Method::HEAD, [index, ""]) | (&Method::OPTIONS, [index, ""]) => { + filter_read_request(index, path_chunks[1], ¶ms, config)? + } + (&Method::GET, [index, "_mapping"]) | (&Method::HEAD, [index, "_mapping"]) | (&Method::OPTIONS, [index, "_mapping"]) => { + filter_read_request(index, path_chunks[1], ¶ms, config)? } _ => Err(ProxyError::NotSupported("unknown endpoint".to_string()))?, }; @@ -169,7 +182,6 @@ pub fn filter_scroll_request( pub fn filter_read_request( index: &str, _endpoint: &str, - _key: &str, _params: &UrlQueryParams, config: &ProxyConfig, ) -> Result { -- cgit v1.2.3