RequestBuilder for JSON objects?

61 views
Skip to first unread message

Damian Nadales

unread,
Feb 22, 2017, 12:10:32 PM2/22/17
to finatra-users
Hi,

To make a request using the Finatra HttpClient I usually find myself repeating this boilerplate:

    val request = RequestBuilder
          .post(url)
          .body(finatraMapper.writeValueAsString(someObject))

    val fResponse  = httpClient.executeJson[T](request)

So I'd like to avoid having to call `finatraMapper.writeValueAsString` every time. This seems like a quite recurrent use case, so would have expected to have something like that already implemented in Finatra but I could not find it. Any ideas?

Thanks,
Damian.

Christopher Coco

unread,
Feb 22, 2017, 1:24:26 PM2/22/17
to Damian Nadales, finatra-users
As mentioned in the documentation and in the README for finatra/httpclient the HttpClient functionality is fairly minimal and barebones.

Pull request accepted!

Thanks,
-c

--
You received this message because you are subscribed to the Google Groups "finatra-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to finatra-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Damian Nadales

unread,
Feb 23, 2017, 9:43:47 AM2/23/17
to finatra-users, damia...@gmail.com
Hi Christopher,

It seems like a low hanging fruit, so I'll try to submit a PR. I've read:

where it is stated that 

    curl -s https://raw.githubusercontent.com/twitter/dodo/develop/bin/build | bash -s -- --no-test finatra

should be run when in the develop branch. 


I completed that step successfully, but running `.sbt` exits with the following error:

    [error] (*:update) sbt.ResolveException: unresolved dependency: com.twitter#scrooge-sbt-plugin;4.13.0-SNAPSHOT: not found


What am I missing?


Thanks in advance,

Damian.

To unsubscribe from this group and stop receiving emails from it, send an email to finatra-user...@googlegroups.com.

Christopher Coco

unread,
Feb 23, 2017, 10:24:47 AM2/23/17
to Damian Nadales, finatra-users
Please check that you have the dependency in your ivy cache: com.twitter#scrooge-sbt-plugin;4.13.0-SNAPSHOT.

Thanks,
-c

To unsubscribe from this group and stop receiving emails from it, send an email to finatra-users+unsubscribe@googlegroups.com.

Damian Nadales

unread,
Feb 24, 2017, 3:28:09 AM2/24/17
to finatra-users, damia...@gmail.com

Please check that you have the dependency in your ivy cache: com.twitter#scrooge-sbt-plugin;4.13.0-SNAPSHOT.
Apparently it is:

➜  ~ find .ivy2/cache -iname "*scrooge*"
.ivy2/cache/com.twitter/scrooge-core_2.11
.ivy2/cache/com.twitter/scrooge-core_2.11/jars/scrooge-core_2.11-4.12.0.jar
.ivy2/cache/com.twitter/scrooge-core_2.11/jars/scrooge-core_2.11-4.13.0.jar
.ivy2/cache/com.twitter/scrooge-core_2.11/srcs/scrooge-core_2.11-4.12.0-sources.jar
.ivy2/cache/com.twitter/scrooge-core_2.11/srcs/scrooge-core_2.11-4.13.0-sources.jar
.ivy2/cache/com.twitter/scrooge-core_2.12
.ivy2/cache/com.twitter/scrooge-generator_2.10
.ivy2/cache/scala_2.10/sbt_0.13/com.twitter/scrooge-sbt-plugin

I've created a ~/.sbt/repositories file to have sbt looking at the local ivy repository:

[repositories]
  local
 
But there seems to be no scrooge-sbt-plugin:

[warn] module not found: com.twitter#scrooge-sbt-plugin;4.13.0-SNAPSHOT
[warn] ==== typesafe-ivy-releases: tried
[warn] ==== sbt-plugin-releases: tried
[warn] ==== local: tried
[warn]   /Users/damian.nadales/.ivy2/local/com.twitter/scrooge-sbt-plugin/scala_2.10/sbt_0.13/4.13.0-SNAPSHOT/ivys/ivy.xml
[warn] ==== sbt-plugin-snapshots: tried
[warn] ==== sbt-plugin-releases: tried
[warn] ==== sonatype-snapshots: tried

Christopher Coco

unread,
Feb 25, 2017, 8:29:58 PM2/25/17
to Damian Nadales, finatra-users
The plugin has to be built with Scala 2.10 (as all sbt plugin must be). Please check that running the dodo script actually completed successfully.

Thanks,
-c

To unsubscribe from this group and stop receiving emails from it, send an email to finatra-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages