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