aboutsummaryrefslogtreecommitdiffstats
path: root/bindings/samples/HelloWorld.c
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/samples/HelloWorld.c')
-rw-r--r--bindings/samples/HelloWorld.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/bindings/samples/HelloWorld.c b/bindings/samples/HelloWorld.c
index 002c4721..4125e77f 100644
--- a/bindings/samples/HelloWorld.c
+++ b/bindings/samples/HelloWorld.c
@@ -412,6 +412,15 @@ static void broadcast(afb_req request)
json_object_put(object);
}
+static void hasperm (afb_req request)
+{
+ const char *perm = afb_req_value(request, "perm");
+ if (afb_req_has_permission(request, perm))
+ afb_req_success_f(request, NULL, "permission %s granted", perm?:"(null)");
+ else
+ afb_req_fail_f(request, "not-granted", "permission %s NOT granted", perm?:"(null)");
+}
+
static int preinit()
{
AFB_NOTICE("hello binding comes to live");
@@ -450,6 +459,7 @@ static const afb_verb_v2 verbs[]= {
{ .verb="callsync", .callback=callsync },
{ .verb="verbose", .callback=verbose },
{ .verb="broadcast", .callback=broadcast },
+ { .verb="hasperm", .callback=hasperm },
{ .verb="exit", .callback=exitnow },
{ .verb=NULL}
};