afb-req-itf: small step for abstracting
[src/app-framework-binder.git] / src / afb-hreq.c
index 19efd4b..613d419 100644 (file)
 
 #include "../include/local-def.h"
 #include "afb-method.h"
+#include "afb-req-itf.h"
 #include "afb-hreq.h"
 
-
 static char empty_string[1] = "";
 
+
 /* a valid subpath is a relative path not looking deeper than root using .. */
 static int validsubpath(const char *subpath)
 {
@@ -229,3 +230,18 @@ int afb_hreq_redirect_to(struct afb_hreq *hreq, const char *url)
        return 1;
 }
 
+const char *afb_hreq_get_cookie(struct afb_hreq *hreq, const char *name)
+{
+       return MHD_lookup_connection_value(hreq->connection, MHD_COOKIE_KIND, name);
+}
+
+const char *afb_hreq_get_argument(struct afb_hreq *hreq, const char *name)
+{
+       return MHD_lookup_connection_value(hreq->connection, MHD_GET_ARGUMENT_KIND, name);
+}
+
+struct afb_req_itf afb_hreq_itf = {
+       .get_cookie = (void*)afb_hreq_get_cookie,
+       .get_argument = (void*)afb_hreq_get_argument
+};
+