Skip to content

Instantly share code, notes, and snippets.

@j2labs
Created June 17, 2012 20:50
Show Gist options
  • Save j2labs/2945706 to your computer and use it in GitHub Desktop.
Save j2labs/2945706 to your computer and use it in GitHub Desktop.
Rollin down the street, rolling braces, sippin on gin n juice. Laid back. With my braces on one line and one line for my braces.
val service = {
path("orders") {
authenticate(httpBasic(realm = "admin area")) { user =>
get {
cacheResults(LruCache(maxCapacity = 1000, timeToIdle = Some(30.minutes))) {
encodeResponse(Deflate) {
completeWith {
// marshal custom object with in-scope marshaller
getOrdersFromDB}}}} ~
post {
(decodeRequest(Gzip) | decodeRequest(NoEncoding)) {
// unmarshal with in-scope unmarshaller
content(as[Order]) { order =>
// transfer to newly spawned actor
detach {
completeWith {
// ... write order to DB
"Order received"}}}}}}} ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment