On Mon, Mar 24, 2014 at 2:14 PM, Thomas Elsgaard <thomas.elsgaard@gmail.com> wrote:
Hi list
I am wondering how it works with YAPP's and the URI they are installed with.
Let's assume that i have following:
out(Arg, 'GET', ["projects", Project, "bugs"]) ->
     % code to handle GET for this URI goes here.
The YAPP, which URI should it be installed with ? If i am installing it with following URI:
It seems to reject: /projects/xfiles/bugs
I can of course install the YAPP as: /projects/xfiles/bugs but that does not really make sense.

My guess is that you're following this:


which means you're probably retrieving the URI using:

out(Arg) ->
     Uri = yaws_api:request_url(Arg),
     Path = string:tokens(Uri#url.path, "/"),

Note that I wrote the code in that article with an appmod in mind. According to the yapp page http://yaws.hyber.org/yapp_intro.yaws a yapp is always installed below the top, which means the "projects" part of your path is probably hidden from you. You might try just printing the Uri variable in your out/1 function to the console using io:format/2, and running

yaws -i

so you get an interactive Erlang shell. Once you see what the Uri is, you can then set up your path pattern matching in your out/3 function clause accordingly.

I might also recommend starting with an appmod instead of a yapp, as appmods are easier.