Created
February 25, 2011 12:11
-
-
Save Dykam/843705 to your computer and use it in GitHub Desktop.
Incremental implementation to get the `listen` function working.
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
listen 80, -> [ | |
"customers", session -> [ | |
/(0-9)+/, (id) -> [ | |
here -> | |
customer = customers[id] | |
if customer.isPrivate and @session.user.id isnt customer.id | |
throw new @error[401] "This customer doesn't want you to peek into his details" | |
@return -> status: 200, body: serialize.toJson customer | |
] | |
] | |
"products", session -> [ | |
/(0-9)+/, (id) -> | |
] | |
session.management url: "session", assign: "session" | |
@catch @error[404], (error) -> | |
# handle error gracefully | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment