Created
June 27, 2012 21:46
-
-
Save gkojax/3007063 to your computer and use it in GitHub Desktop.
FinagleのhttpのParamMatcher使ってみた。
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
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