[erlang-questions] Creation of HTTP URLs with arguments

Steve Vinoski vinoski@REDACTED
Mon Oct 10 19:16:22 CEST 2011


On Mon, Oct 10, 2011 at 11:48 AM, Torben Hoffmann
<torben.lehoff@REDACTED> wrote:
> Hi,
> I want to create URLs that looks like this:
> http://my.coolest.site.com?arg1=val1,arg2=val2

The usual standard format is

http://my.coolest.site.com?arg1=val1&arg2=val2

Any reason you want a comma instead of an ampersand there?

> Are there any libraries out there that makes this kind of creation easy? I
> have tried playing with ibrowse, but that was not a success (might be me at
> fault more than ibrowse ;-))
> I am dreaming of something that takes a proplist ([{Key, Value}]) and does
> all the magic for me, but I am open to other approaches as long as my life
> becomes easier than fiddling with strings.
> Otherwise, I will just create my own library for this, but it seems like a
> thing that others have might have had to do before.

In yaws there's yaws_api:format_url which takes a url record and can
produce the above (with the ampersand rather than the comma).

https://github.com/klacke/yaws/blob/master/src/yaws_api.erl#L1349

--steve



More information about the erlang-questions mailing list