Created
January 15, 2012 21:36
-
-
Save seancorfield/1617493 to your computer and use it in GitHub Desktop.
Example routes
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
routes = [ | |
{ "/email/bounced/:email" = "/user/email_event/email/:email/event/bounced", hint = "Mark an email address as bounced." }, | |
{ "/email/updated/:email" = "/user/email_event/email/:email/event/updated", hint = "Mark an email address as updated." }, | |
{ "/email/validated/:email" = "/user/email_event/email/:email/event/validated", hint = "Mark an email address as validated." }, | |
{ "/email/:email" = "/user/email/email/:email", hint = "Return the status of an email address." }, | |
{ "/routes" = "/auth/routes", hint = "Returns the available routes." }, | |
{ "/user/:id" = "/user/view/id/:id", hint = "Return information about a user." }, | |
{ "/active" = "/site/active", hint = "Return the active site IDs." }, | |
{ "*" = "/main/default" } | |
] | |
public void function view( struct rc ) { | |
if ( structKeyExists( rc, "id" ) && isNumeric( rc.id ) ) { | |
var user = variables.userService.get( rc.id ); | |
if ( !user.getId() ) { | |
throw "No such user"; | |
} | |
// the API publishes a simple struct with the following columns: | |
var apiColumns = listToArray( "id,username,email,firstName,lastName,siteId,gender,dateOfBirth" ); | |
rc.user = { }; | |
for ( var column in apiColumns ) { | |
rc.user[ column ] = user.get( column ); | |
} | |
// fix up formatting: | |
rc.user.dateOfBirth = dateFormat( rc.user.dateOfBirth, "yyyy-mm-dd" ); | |
} else { | |
throw "No such user"; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment