let alone a users route

This commit is contained in:
Sijmen 2019-11-01 01:48:35 +01:00
parent 75134c0cf6
commit 588cac6e95
Signed by: vijfhoek
GPG key ID: DAF7821E067D9C48
2 changed files with 9 additions and 1 deletions

View file

@ -21,7 +21,7 @@
login(username:atom, password:atom). login(username:atom, password:atom).
:- json_object :- json_object
user(username:atom, password_hash:atom). user(username:atom).
:- persistent :- persistent
user(username:atom, password_hash:atom). user(username:atom, password_hash:atom).
@ -35,3 +35,4 @@
:- consult('routes/products.pl'). :- consult('routes/products.pl').
:- consult('routes/login.pl'). :- consult('routes/login.pl').
:- consult('routes/users.pl').

7
routes/users.pl Normal file
View file

@ -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).