diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-05 20:17:51 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-05 20:19:03 +0200 |
commit | 659ed5b33cf70a6898697c7c5886ae068a3be966 (patch) | |
tree | 9887be03351861823d59081321072eb568298241 | |
parent | 9dbd617046f19979d8c8ed9e31e4b71d18e20235 (diff) | |
download | pies-659ed5b33cf70a6898697c7c5886ae068a3be966.tar.gz pies-659ed5b33cf70a6898697c7c5886ae068a3be966.tar.bz2 |
control interface: pass JSON as query for GET, DELETE, and PUT
-rw-r--r-- | src/ctl.c | 13 | ||||
-rw-r--r-- | src/piesctl.c | 2 |
2 files changed, 7 insertions, 8 deletions
@@ -917,7 +917,7 @@ static struct ctlio_resource * find_resource (struct ctlio *io, const char *endpoint) { struct ctlio_resource *p; - size_t len = strlen (endpoint); + size_t len = strcspn (endpoint, "?"); if (len == 0) return NULL; @@ -927,7 +927,9 @@ find_resource (struct ctlio *io, const char *endpoint) for (p = restab; p->uri; p++) if (len >= p->uri_len && memcmp (p->uri, endpoint, p->uri_len) == 0 - && (endpoint[p->uri_len] == 0 || endpoint[p->uri_len] == '/')) + && (endpoint[p->uri_len] == 0 + || endpoint[p->uri_len] == '/' + || endpoint[p->uri_len] == '?')) return p; return NULL; } @@ -935,11 +937,8 @@ find_resource (struct ctlio *io, const char *endpoint) static char * json_extract (char *uri) { - char *p = strrchr (uri, '/'); - if (p && (strchr ("\"{[", p[1]) - || strcmp ("true", p + 1) == 0 - || strcmp ("false", p + 1) == 0 - || strcmp ("null", p + 1) == 0)) + char *p = strchr (uri, '?'); + if (p) { *p++ = 0; return p; diff --git a/src/piesctl.c b/src/piesctl.c index d8afbfe..da2e621 100644 --- a/src/piesctl.c +++ b/src/piesctl.c @@ -1435,7 +1435,7 @@ parse_condition_to_uri (char const *base, int argc, char **argv, int mandatory) .data = acc }; if (base) - grecs_txtacc_grow_char (acc, '/'); + grecs_txtacc_grow_char (acc, '?'); json_format_value (val, &fmt); json_value_free (val); } |