Created
May 6, 2012 15:52
-
-
Save JosephLenton/2623046 to your computer and use it in GitHub Desktop.
example controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* /users/edit/<user id> | |
* I am editing a user. | |
*/ | |
get( users, edit, ID ) :- | |
number( ID ), | |
is_admin or session( id, ID ), | |
users:get_user( ID, User ), | |
users:view( edit, User ). | |
/* | |
* /users/edit | |
* I am editing a user, haven't said who, so default to edit me. | |
*/ | |
get( users, edit ) :- | |
session( id, MyID ), | |
get( users, edit, MyID ). | |
/* | |
* /users/<user id> | |
* View a specific user. | |
*/ | |
get( users, ID ) :- | |
number( ID ), | |
users:get_username( ID, Username ), | |
users:view( Username ). | |
/* | |
* /users/me | |
* View a user, default to myself. | |
*/ | |
get( users, me ) :- | |
session( id, MyID ), | |
get( users, MyID ). | |
/* | |
* /users/<something> | |
* View a user, but they weren't found. | |
*/ | |
get( users, _ ) :- | |
users:view( not_found ). | |
/* | |
* /users | |
* List all users. | |
*/ | |
get( users ) :- | |
users:get_all_users( Users ), | |
users:view( list, Users ). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment