From 588cac6e95d3bd9d619ef3eead761880caeaa2d7 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Fri, 1 Nov 2019 01:48:35 +0100 Subject: [PATCH] let alone a users route --- main.pl | 3 ++- routes/users.pl | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 routes/users.pl diff --git a/main.pl b/main.pl index 07c568a..a344b7c 100644 --- a/main.pl +++ b/main.pl @@ -21,7 +21,7 @@ login(username:atom, password:atom). :- json_object - user(username:atom, password_hash:atom). + user(username:atom). :- persistent user(username:atom, password_hash:atom). @@ -35,3 +35,4 @@ :- consult('routes/products.pl'). :- consult('routes/login.pl'). +:- consult('routes/users.pl'). diff --git a/routes/users.pl b/routes/users.pl new file mode 100644 index 0000000..e49cc5e --- /dev/null +++ b/routes/users.pl @@ -0,0 +1,7 @@ +:- http_handler(root(users), users_route, []). + +% GET /users +users_route(_Request) :- + bagof(user(Username), user(Username, _), Users), + prolog_to_json(Users, Json), + reply_json(Json).