Skip to content

Instantly share code, notes, and snippets.

@Dykam
Created February 25, 2011 12:11
Show Gist options
  • Save Dykam/843705 to your computer and use it in GitHub Desktop.
Save Dykam/843705 to your computer and use it in GitHub Desktop.
Incremental implementation to get the `listen` function working.
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