Skip to content

Instantly share code, notes, and snippets.

@gkojax
Created June 27, 2012 21:46
Show Gist options
  • Save gkojax/3007063 to your computer and use it in GitHub Desktop.
Save gkojax/3007063 to your computer and use it in GitHub Desktop.
FinagleのhttpのParamMatcher使ってみた。
class Respond extends Service[Request, Response] {
def apply(request: Request) = {
object KI extends IntParamMatcher("k")
object K extends ParamMatcher("k")
val text = (Path(request.path) :? request.params) match {
case Root / "name" / name :? KI(k) =>
"Hello, %s i %s!".format(name, k)
case Root / "name" / name :? K(k) =>
"Hello, %s %s!".format(name, k)
case _ =>
"Hello, world!"
}
val response = Response()
response.setContentString(text)
Future.value(response)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment