+/*
+ * retrieves the 'appid' in parameters received with the
+ * request 'req' for the 'method'.
+ *
+ * Returns 1 in case of success.
+ * Otherwise, if the 'appid' can't be retrieved, an error stating
+ * the bad request is replied for 'req' and 0 is returned.
+ */
+static int onappid(struct afb_req req, const char *method, const char **appid)
+{
+ struct json_object *json;
+
+ /* get the paramaters of the request */
+ json = afb_req_json(req);
+
+ /* get the appid if any */
+ if (!wrap_json_unpack(json, "s", appid)
+ || !wrap_json_unpack(json, "{si}", _id_, appid)) {
+ /* found */
+ INFO("method %s called for %s", method, *appid);
+ return 1;
+ }
+
+ /* nothing appropriate */
+ INFO("bad request method %s: %s", method,
+ json_object_to_json_string(json));
+ bad_request(req);
+ return 0;
+}
+