diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-03-25 17:19:54 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-03-25 17:19:54 +0000 |
commit | 19c380f237708910a12f14e98960919e9fe6d865 (patch) | |
tree | 0f5ede8bd4b834b0acd083423c2828cadb4b3665 /src/rest | |
parent | 5afc084a9c29b980bf00fddd7372fa15db63de76 (diff) | |
download | gnunet-19c380f237708910a12f14e98960919e9fe6d865.tar.gz gnunet-19c380f237708910a12f14e98960919e9fe6d865.zip |
-more rest handling
Diffstat (limited to 'src/rest')
-rw-r--r-- | src/rest/rest.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/rest/rest.c b/src/rest/rest.c index 0b843ec61..ec46e1273 100644 --- a/src/rest/rest.c +++ b/src/rest/rest.c | |||
@@ -68,6 +68,7 @@ struct JsonApiResponse | |||
68 | int res_count; | 68 | int res_count; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | |||
71 | /** | 72 | /** |
72 | * JSON API | 73 | * JSON API |
73 | */ | 74 | */ |
@@ -296,4 +297,39 @@ GNUNET_REST_create_json_response (const char *data) | |||
296 | 297 | ||
297 | } | 298 | } |
298 | 299 | ||
300 | int | ||
301 | GNUNET_REST_handle_request (struct RestConnectionDataHandle *conn, | ||
302 | const struct GNUNET_REST_RestConnectionHandler *handlers, | ||
303 | void *cls) | ||
304 | { | ||
305 | int count; | ||
306 | int i; | ||
307 | char *url; | ||
308 | |||
309 | count = 0; | ||
310 | |||
311 | while (NULL != handlers[count].method) | ||
312 | count++; | ||
313 | |||
314 | GNUNET_asprintf (&url, "%s", conn->url); | ||
315 | if (url[strlen (url)-1] == '/') | ||
316 | url[strlen (url)-1] = '\0'; | ||
317 | |||
318 | for (i = 0; i < count; i++) | ||
319 | { | ||
320 | if (0 != strcasecmp (conn->method, handlers[count].method)) | ||
321 | break; | ||
322 | if (strlen (url) < strlen (handlers[count].namespace)) | ||
323 | break; | ||
324 | if (GNUNET_NO == GNUNET_REST_namespace_match (url, handlers[count].namespace)) | ||
325 | break; | ||
326 | //Match | ||
327 | handlers[count].proc (conn, (const char*)url, cls); | ||
328 | GNUNET_free (url); | ||
329 | return GNUNET_YES; | ||
330 | } | ||
331 | GNUNET_free (url); | ||
332 | return GNUNET_NO; | ||
333 | } | ||
334 | |||
299 | /* end of rest.c */ | 335 | /* end of rest.c */ |