aboutsummaryrefslogtreecommitdiff
path: root/src/api/k2v
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-12-12 11:56:40 +0100
committerAlex Auvolat <alex@adnab.me>2022-12-12 12:05:37 +0100
commita0abf417626be8d120f660c582195747d131b88b (patch)
tree585aa99a5fb41511460580b4cf7df7fa851fc5e4 /src/api/k2v
parent980572a8872c56ea9572ff03579ebb9a65013775 (diff)
downloadgarage-a0abf417626be8d120f660c582195747d131b88b.tar.gz
garage-a0abf417626be8d120f660c582195747d131b88b.zip
Fix router keyword handling (fix #442)router-keywords-fix
Diffstat (limited to 'src/api/k2v')
-rw-r--r--src/api/k2v/router.rs43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/api/k2v/router.rs b/src/api/k2v/router.rs
index 50e6965b..e7a3dd69 100644
--- a/src/api/k2v/router.rs
+++ b/src/api/k2v/router.rs
@@ -96,7 +96,7 @@ impl Endpoint {
fn from_get(partition_key: String, query: &mut QueryParameters<'_>) -> Result<Self, Error> {
router_match! {
@gen_parser
- (query.keyword.take().unwrap_or_default().as_ref(), partition_key, query, None),
+ (query.keyword.take().unwrap_or_default(), partition_key, query, None),
key: [
EMPTY if causality_token => PollItem (query::sort_key, query::causality_token, opt_parse::timeout),
EMPTY => ReadItem (query::sort_key),
@@ -111,7 +111,7 @@ impl Endpoint {
fn from_search(partition_key: String, query: &mut QueryParameters<'_>) -> Result<Self, Error> {
router_match! {
@gen_parser
- (query.keyword.take().unwrap_or_default().as_ref(), partition_key, query, None),
+ (query.keyword.take().unwrap_or_default(), partition_key, query, None),
key: [
],
no_key: [
@@ -125,7 +125,7 @@ impl Endpoint {
fn from_head(partition_key: String, query: &mut QueryParameters<'_>) -> Result<Self, Error> {
router_match! {
@gen_parser
- (query.keyword.take().unwrap_or_default().as_ref(), partition_key, query, None),
+ (query.keyword.take().unwrap_or_default(), partition_key, query, None),
key: [
EMPTY => HeadObject(opt_parse::part_number, query_opt::version_id),
],
@@ -140,7 +140,7 @@ impl Endpoint {
fn from_post(partition_key: String, query: &mut QueryParameters<'_>) -> Result<Self, Error> {
router_match! {
@gen_parser
- (query.keyword.take().unwrap_or_default().as_ref(), partition_key, query, None),
+ (query.keyword.take().unwrap_or_default(), partition_key, query, None),
key: [
],
no_key: [
@@ -155,7 +155,7 @@ impl Endpoint {
fn from_put(partition_key: String, query: &mut QueryParameters<'_>) -> Result<Self, Error> {
router_match! {
@gen_parser
- (query.keyword.take().unwrap_or_default().as_ref(), partition_key, query, None),
+ (query.keyword.take().unwrap_or_default(), partition_key, query, None),
key: [
EMPTY => InsertItem (query::sort_key),
@@ -169,7 +169,7 @@ impl Endpoint {
fn from_delete(partition_key: String, query: &mut QueryParameters<'_>) -> Result<Self, Error> {
router_match! {
@gen_parser
- (query.keyword.take().unwrap_or_default().as_ref(), partition_key, query, None),
+ (query.keyword.take().unwrap_or_default(), partition_key, query, None),
key: [
EMPTY => DeleteItem (query::sort_key),
],
@@ -232,21 +232,18 @@ impl Endpoint {
// parameter name => struct field
generateQueryParameters! {
- "prefix" => prefix,
- "start" => start,
- "causality_token" => causality_token,
- "end" => end,
- "limit" => limit,
- "reverse" => reverse,
- "sort_key" => sort_key,
- "timeout" => timeout
-}
-
-mod keywords {
- //! This module contain all query parameters with no associated value
- //! used to differentiate endpoints.
- pub const EMPTY: &str = "";
-
- pub const DELETE: &str = "delete";
- pub const SEARCH: &str = "search";
+ keywords: [
+ "delete" => DELETE,
+ "search" => SEARCH
+ ],
+ fields: [
+ "prefix" => prefix,
+ "start" => start,
+ "causality_token" => causality_token,
+ "end" => end,
+ "limit" => limit,
+ "reverse" => reverse,
+ "sort_key" => sort_key,
+ "timeout" => timeout
+ ]
}