Skip to content

Instantly share code, notes, and snippets.

@deanh
Last active December 22, 2015 06:18
Show Gist options
  • Save deanh/6429841 to your computer and use it in GitHub Desktop.
Save deanh/6429841 to your computer and use it in GitHub Desktop.
get("/thing/:id", operation(getThingAuraById)) {
val id = params("id")
val Some(limit) = ParamValidator.asInteger(params.getOrElse("limit", "100"))
val Some(offset) = ParamValidator.asInteger(params.getOrElse("offset", "0"))
ParamValidator.asInteger(id) match {
case Some(id) => {
new AsyncResult { val is =
// this returns a Finagle Future - I want an implicit in scope here to do the
// conversion
auraClient.auraByThingId(id, limit = limit, offset = offset) map { aura =>
JsonParticleCollectionView(aura.toList, nextThingUrl(id, offset, limit))
}
}
}
case None => NotFound(ResponseError("Invalid id: %s".format(id)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment