Twitter Finagle is an amazing framework for RPC communication, and my interest is its HTTP features for creating RESTful APIs.
As I bloged at codemountain, I’m using finagle for a personal project. Don’t know how far it will go, but the facts is that I’m learning Finagle a lot.
During this project I needed to extract from the query string, a param to be parsed to a twitter.util.Time. I ended up with a Param Matcher to be used my a pattern match agains the requested path. The use of this Param Patcher is:
The source of DateParamMatcher is the following.
Finagle also provides an abstract com.twitter.finagle.http.path.ParamMatcher
as well as LongParamMatcher
and IntParamMatcher
in the same package. They are actually Scala Extractors (very well explained here by @codemonkeyism). This is a practical way to extract values from a query string and put it available at your code already parsed.
Note that if the param named requestTimeParam
is not present or carries a invalid value for Time
in the query string the None
value is returned.
Although easy to build and extract params from query string and requested path, it is not a Finagle strength. It is kinda limited. A better abstraction is offered by Unfiltered(another @n8han’s great job).
Hope you enjoy it.