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 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.
17 * @author Martin Schanzenbach
20 * API for helper library to parse/create REST
22 * @defgroup rest REST library
23 * Helper library to parse/create REST
26 #ifndef GNUNET_REST_LIB_H
27 #define GNUNET_REST_LIB_H
29 #include "gnunet_util_lib.h"
30 #include <microhttpd.h>
32 #define GNUNET_REST_HANDLER_END {NULL, NULL, NULL}
34 struct GNUNET_REST_RequestHandle
37 * Map of url parameters
39 struct GNUNET_CONTAINER_MultiHashMap *url_param_map;
44 struct GNUNET_CONTAINER_MultiHashMap *header_param_map;
47 * The HTTP method as MHD value (see microhttpd.h)
67 struct GNUNET_REST_RequestHandlerError
73 struct GNUNET_REST_RequestHandler
76 * Http method to handle
83 const char *namespace;
88 void (*proc) (struct GNUNET_REST_RequestHandle *handle,
96 * Iterator called on obtained result for a REST result.
99 * @param resp the response
100 * @param status status code (HTTP)
102 typedef void (*GNUNET_REST_ResultProcessor) (void *cls,
103 struct MHD_Response *resp,
107 * Check if namespace is in URL.
109 * @param url URL to check
110 * @param namespace namespace to check against
111 * @return GNUNET_YES if namespace matches
114 GNUNET_REST_namespace_match (const char *url, const char *namespace);
117 * Create REST MHD response
120 * @return MHD response
123 GNUNET_REST_create_response (const char *data);
127 GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn,
128 const struct GNUNET_REST_RequestHandler *handlers,
129 struct GNUNET_REST_RequestHandlerError *err,
135 /** @} */ /* end of group */