diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-08-26 17:35:18 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-26 17:41:57 -0700 |
commit | adfc678a8a556ea72c3602d14dcc500d2bfa2d0f (patch) | |
tree | 33d5546a9b297fd3c32b427fc558bf5bf8c37ae7 /src/lib.rs | |
parent | b2e116eaa6d4e8ad24208db1eafdc59531bd20f0 (diff) | |
download | es-public-proxy-adfc678a8a556ea72c3602d14dcc500d2bfa2d0f.tar.gz es-public-proxy-adfc678a8a556ea72c3602d14dcc500d2bfa2d0f.zip |
more endpoints/methods
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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<Body, ProxyError> { |