aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2015-03-25 17:19:54 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2015-03-25 17:19:54 +0000
commit19c380f237708910a12f14e98960919e9fe6d865 (patch)
tree0f5ede8bd4b834b0acd083423c2828cadb4b3665 /src/include
parent5afc084a9c29b980bf00fddd7372fa15db63de76 (diff)
downloadgnunet-19c380f237708910a12f14e98960919e9fe6d865.tar.gz
gnunet-19c380f237708910a12f14e98960919e9fe6d865.zip
-more rest handling
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_rest_lib.h50
-rw-r--r--src/include/gnunet_rest_plugin.h22
2 files changed, 51 insertions, 21 deletions
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h
index 19a0168e5..cc02f01d0 100644
--- a/src/include/gnunet_rest_lib.h
+++ b/src/include/gnunet_rest_lib.h
@@ -36,6 +36,52 @@
36 36
37#define GNUNET_REST_JSONAPI_KEY_TYPE "type" 37#define GNUNET_REST_JSONAPI_KEY_TYPE "type"
38 38
39#define GNUNET_REST_HANDLER_END {NULL, NULL, NULL}
40
41struct RestConnectionDataHandle
42{
43 struct GNUNET_CONTAINER_MultiHashMap *url_param_map;
44 const char *method;
45 const char *url;
46 const char *data;
47 size_t data_size;
48
49};
50
51struct GNUNET_REST_RestConnectionHandler
52{
53 /**
54 * Http method to handle
55 */
56 const char *method;
57
58 /**
59 * Namespace to handle
60 */
61 const char *namespace;
62
63 /**
64 * callback handler
65 */
66 void (*proc) (struct RestConnectionDataHandle *handle,
67 const char *url,
68 void *cls);
69
70};
71
72
73/**
74 * Iterator called on obtained result for a REST result.
75 *
76 * @param cls closure
77 * @param resp the response
78 * @param status status code (HTTP)
79 */
80typedef void (*GNUNET_REST_ResultProcessor) (void *cls,
81 struct MHD_Response *resp,
82 int status);
83
84
39/** 85/**
40 * Resource structs for JSON API 86 * Resource structs for JSON API
41 */ 87 */
@@ -152,5 +198,9 @@ GNUNET_REST_namespace_match (const char *url, const char *namespace);
152GNUNET_REST_create_json_response (const char *data); 198GNUNET_REST_create_json_response (const char *data);
153 199
154 200
201int
202GNUNET_REST_handle_request (struct RestConnectionDataHandle *conn,
203 const struct GNUNET_REST_RestConnectionHandler *handlers,
204 void *cls);
155 205
156#endif 206#endif
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h
index e085ccf32..e1eabd813 100644
--- a/src/include/gnunet_rest_plugin.h
+++ b/src/include/gnunet_rest_plugin.h
@@ -27,6 +27,7 @@
27#define GNUNET_REST_PLUGIN_H 27#define GNUNET_REST_PLUGIN_H
28 28
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_rest_lib.h"
30#include "microhttpd.h" 31#include "microhttpd.h"
31 32
32#ifdef __cplusplus 33#ifdef __cplusplus
@@ -39,27 +40,6 @@ extern "C"
39 40
40 41
41/** 42/**
42 * Iterator called on obtained result for a REST result.
43 *
44 * @param cls closure
45 * @param resp the response
46 * @param status status code (HTTP)
47 */
48typedef void (*GNUNET_REST_ResultProcessor) (void *cls,
49 struct MHD_Response *resp,
50 int status);
51
52struct RestConnectionDataHandle
53{
54 struct GNUNET_CONTAINER_MultiHashMap *url_param_map;
55 const char *method;
56 const char *url;
57 const char *data;
58 size_t data_size;
59
60};
61
62/**
63 * @brief struct returned by the initialization function of the plugin 43 * @brief struct returned by the initialization function of the plugin
64 */ 44 */
65struct GNUNET_REST_Plugin 45struct GNUNET_REST_Plugin