Extract arguments from a Erlang URL

Asked

Viewed 51 times

2

I need a lot of help in Erlang because I’m a beginner in language. I am doing a job with some friends that consists in the development of a bus oriented to service, allowing to manipulate several requests. I am looking for a solution of how the URL from the bus client will be treated regarding the extraction of arguments.

The parameters can be from the URL ( URL/parametro1/parametro2 ) or Query URL type?param=value&param1=value1

If anyone has any code examples of how it could be done, I’d be grateful. For a better view of the problem the bus code being built is found in GITHUB at the link:

https://github.com/PPCA2014/ppca_soa/

Grateful From Now

1 answer

0

The module http_uri has a function parse able to interpret a URL. Calling it with the default options:

parse("http://example.com:8080/path/to/resource?q1=foo&q2=bar#fragmento")

Upshot:

{http,[],"example.com",8080,"/path/to/resource","?q1=foo&q2=bar#fragmento"}

Example in the ideone. There are some options to customize the interpretation of the URL (see the documentation for parse/2), but I didn’t quite understand how to use them (I’m also a beginner in Erlang).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.