beginner issues with rapture.net (0.10.0)

34 views
Skip to first unread message

Joune Panday

unread,
Oct 27, 2014, 12:52:01 PM10/27/14
to raptur...@googlegroups.com
Hi Jon (and friends..)

I must say I fell in love with rapture during your talk at scala.io!
(actually I had already fallen in love with it last year, but then I somehow forgot about it! -shame)

So this time I decided to try it out for real, as I'm playing with a couchDB instance. 

I'm not using the json part yet (although it's probably the most beautiful part of rapture), but just the http client for now. 

I bumped into 2 little problems (in bold below).. here's what I've got..

scala> import rapture._
import rapture._

scala> import core._, io._, net._, uri._, codec._
import core._
import io._
import net._
import uri._
import codec._

scala> import encodings.`UTF-8`
import encodings.UTF$minus8

scala> import modes.throwExceptions
import modes.throwExceptions

scala> val url = uri"http://localhost:49153"
url: rapture.net.HttpUrl = http://localhost:49153/

scala> url.slurp[Char]
res0: String = 
"{"couchdb":"Welcome","version":"1.2.0"}
"

scala> (url / "_all_dbs").slurp[Char] // this is adding an extra slash :(
java.io.IOException: Server returned HTTP response code: 400 for URL: http://localhost:49153//_all_dbs
...

scala> uri"http://localhost:49153/test".post("""{"hello": "world"}""")
<console>:28: error: an implicit TimeSystem is required; please import timeSystems.numeric or timeSystems.javaUtil
Error occurred in an application involving default arguments.
       uri"http://localhost:49153/test".post("""{"hello": "world"}""")


scala> import timeSystems.numeric
import timeSystems.numeric

scala> uri"http://localhost:49153/test".post("""{"hello": "world"}""")
<console>:29: error: an implicit TimeSystem is required; please import timeSystems.numeric or timeSystems.javaUtil
Error occurred in an application involving default arguments.
       uri"http://localhost:49153/test".post("""{"hello": "world"}""")
                                            ^
scala> implicit val ts = timeSystems.numeric
ts: rapture.core.TimeSystem[Long,Long] = rapture.core.timeSystems$$anon$1@1b85bc73

scala> uri"http://localhost:49153/test".post("""{"hello": "world"}""")
<console>:30: error: an implicit TimeSystem is required; please import timeSystems.numeric or timeSystems.javaUtil
Error occurred in an application involving default arguments.
       uri"http://localhost:49153/test".post("""{"hello": "world"}""")
                                            ^
... :(

Can someone please help me get around that second issue?

Cheers

Jon Pretty

unread,
Oct 28, 2014, 11:30:07 AM10/28/14
to raptur...@googlegroups.com
Hi Joune,

Thanks for coming back! The JSON library is at least more complete than Rapture IO (I'm happy to call it version 1.0, whereas Rapture IO is still a 0.x release), but now that Rapture JSON is more mature, I'm going to start focusing on Rapture IO more.

The first issue is a bug. I'll file an issue.

And so is the second one, though I think it's an underlying Scala problem with type inference which is causing it. I'm going to change the HTTP Post API to avoid it in a later release, but you should be able to work around the problem for now by specifying the timeout explicitly, like this:

   import timeSystems.numeric
   uri"http://localhost:49153/test".post("""{"hello": "world"}""", timeout = 10000L)

Let me know if that avoids the problem!

Thanks,
Jon

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



--
Jon Pretty | @propensive

Joune

unread,
Oct 28, 2014, 12:27:58 PM10/28/14
to raptur...@googlegroups.com
Excellent, it works with the explicit timeout :)
thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "Rapture users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rapture-users/dh6TvwrPQl4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rapture-user...@googlegroups.com.

Jon Pretty

unread,
Oct 28, 2014, 12:33:35 PM10/28/14
to raptur...@googlegroups.com
Great!

Sorry that part of the API is so rough around the edges at the moment - you're not the first person to experience the same problem!

Cheers,
Jon

Joune

unread,
Oct 28, 2014, 12:45:45 PM10/28/14
to rapture-users
No problem, I understand the meaning of 0.10.. 

If I may suggest, a few (more) examples on how it's supposed to be used would be helpful to get people started.. 
I did have to look around the code to find the put and post methods.. 

Still these APIs are very inspiring, thanks for the great work, and for the support!

Jon Pretty

unread,
Oct 28, 2014, 12:47:56 PM10/28/14
to raptur...@googlegroups.com
Thanks, Joune! It's still incomplete, but there's currently this:

  https://github.com/propensive/rapture-io/blob/master/doc/introduction.md

Cheers,
Jon
Reply all
Reply to author
Forward
0 new messages