First set of third-party additions. #14

wants to merge 5 commits into


None yet

4 participants


It seems that any third-party libraries that are part of Dispatch would be treated as a separate jar that could be downloaded. Given that, this is just a simple foursquare library to get the ball rolling.

Mostly I want to get people's thoughts on a good way to bring in support for popular api's, etc..


There is a problem in that any HTTP status code that comes back which isn't 200 throws an exception. As seen by this line:

It would be nice to not throw that, but instead return that so we can deal with it. A lot of HTTP status codes don't mean failure.


Thats only if you use the OkHandler (i.e. Http(url("") OK as.String)) You could always use the > handler


I know this is a 2 year old thread but I'll add the following to illustrate the last comment:

   * Accept the specified status code, throw an exception for any other status codes.
   * Use like `Http(req > acceptOnly(401, as.String))`.
   * For some reason the parser does not like `Http(req acceptOnly(401) as.String)``
   * so I had to code the class this way instead of an implicit class.
  case class acceptOnly[T](code: Int, f: Response => T)
    extends dispatch.FunctionHandler(f) {

    override def onStatusReceived(status: HttpResponseStatus) = {
      if (status.getStatusCode == code)
      else throw StatusCode(status.getStatusCode)
@n8han n8han closed this May 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment