2 This file is part of GNUnet
3 Copyright (C) 2010-2015 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Martin Schanzenbach
23 * API for helper library to parse/create REST
25 * @defgroup rest REST library
26 * Helper library to parse/create REST
29 #ifndef GNUNET_REST_LIB_H
30 #define GNUNET_REST_LIB_H
32 #include "gnunet_util_lib.h"
33 #include <microhttpd.h>
35 #define GNUNET_REST_HANDLER_END {NULL, NULL, NULL}
37 struct GNUNET_REST_RequestHandle
40 * Map of url parameters
42 struct GNUNET_CONTAINER_MultiHashMap *url_param_map;
47 struct GNUNET_CONTAINER_MultiHashMap *header_param_map;
50 * The HTTP method as MHD value (see microhttpd.h)
70 struct GNUNET_REST_RequestHandlerError
76 struct GNUNET_REST_RequestHandler
79 * Http method to handle
86 const char *namespace;
91 void (*proc) (struct GNUNET_REST_RequestHandle *handle,
99 * Iterator called on obtained result for a REST result.
102 * @param resp the response
103 * @param status status code (HTTP)
105 typedef void (*GNUNET_REST_ResultProcessor) (void *cls,
106 struct MHD_Response *resp,
110 * Check if namespace is in URL.
112 * @param url URL to check
113 * @param namespace namespace to check against
114 * @return GNUNET_YES if namespace matches
117 GNUNET_REST_namespace_match (const char *url, const char *namespace);
120 * Create REST MHD response
123 * @return MHD response
126 GNUNET_REST_create_response (const char *data);
130 GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn,
131 const struct GNUNET_REST_RequestHandler *handlers,
132 struct GNUNET_REST_RequestHandlerError *err,
138 /** @} */ /* end of group */