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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Martin Schanzenbach
25 * API for helper library to parse/create REST
27 * @defgroup rest REST library
28 * Helper library to parse/create REST
31 #ifndef GNUNET_REST_LIB_H
32 #define GNUNET_REST_LIB_H
34 #include "gnunet_util_lib.h"
35 #include "microhttpd.h"
37 #define GNUNET_REST_HANDLER_END {NULL, NULL, NULL}
39 struct GNUNET_REST_RequestHandle
41 struct GNUNET_CONTAINER_MultiHashMap *url_param_map;
48 struct GNUNET_REST_RequestHandlerError
54 struct GNUNET_REST_RequestHandler
57 * Http method to handle
64 const char *namespace;
69 void (*proc) (struct GNUNET_REST_RequestHandle *handle,
77 * Iterator called on obtained result for a REST result.
80 * @param resp the response
81 * @param status status code (HTTP)
83 typedef void (*GNUNET_REST_ResultProcessor) (void *cls,
84 struct MHD_Response *resp,
88 * Check if namespace is in URL.
90 * @param url URL to check
91 * @param namespace namespace to check against
92 * @retun GNUNET_YES if namespace matches
95 GNUNET_REST_namespace_match (const char *url, const char *namespace);
98 * Create JSON API MHD response
100 * @param data JSON result
101 * @retun MHD response
104 GNUNET_REST_create_json_response (const char *data);
108 GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn,
109 const struct GNUNET_REST_RequestHandler *handlers,
110 struct GNUNET_REST_RequestHandlerError *err,
116 /** @} */ /* end of group */