Skip to content

Instantly share code, notes, and snippets.

@seancorfield
Created January 15, 2012 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seancorfield/1617493 to your computer and use it in GitHub Desktop.
Save seancorfield/1617493 to your computer and use it in GitHub Desktop.
Example routes
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