How can I create a URL programmatically (e.g. without uri"some hard-coded string")?

18 views
Skip to first unread message

Emre Sevinc

unread,
Oct 31, 2014, 9:01:57 AM10/31/14
to raptur...@googlegroups.com
Hello,

According to Rapture I/O web page, it is possible to very easily create an URL to be slurped  when we have a hard-coded string, e.g.

 scala> uri"http://cnn.com"
 res17: rapture.net.HttpUrl = http://cnn.com/

But now let's assume I want to achieve the same effect, this time by passing a val, e.g. let's say I have:

   val src = "http://cnn.com/"

And I want to use this val instead of the hard-coded string to create the same rapture.net.HttpUrl object.

How can I do this?





Jon Pretty

unread,
Oct 31, 2014, 10:16:44 AM10/31/14
to raptur...@googlegroups.com
Hi Emre,

You'll need to use the `Http.parse(myString)` method. This works on `http` and `https` resources, but not other URI schemes, so if you need to use something else, unfortunately you'll have to know the scheme in advance, or attempt the parsing with different companion objects (e.g. `File`).

Hope that helps!
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

Emre Sevinc

unread,
Oct 31, 2014, 10:27:23 AM10/31/14
to raptur...@googlegroups.com
Hello Jon,

Thanks for the quick help. Indeed, Http.parse nailed it! Thank you very much. (I only needed http and https resources, so this is perfectly fine for my use-case).

Cheers,
Emre


--
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/qcDT3RaRPSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rapture-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Emre Sevinc
Reply all
Reply to author
Forward
0 new messages