Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. Appmods: Dynamic Content in Yaws > When the URI Does Not Correspond to a Fil...

When the URI Does Not Correspond to a File

In the case of .yaws files, the HTTP path sent to the server will map directly onto the file. The user will make a request like “/get-stock-price.yaws” and Yaws will invoke the code in the file get-stock-price.yaws.

However, in an appmod the programmer has to translate the request URI into some action directly. This transfers some workload from the web server to the developer, but it is not overly hard to do.

In order to do this we need to find out what URI the user requested from within our handler function. This can be set in one of several places in the #arg record. It will be in pathinfo or in fullpath (actually both).

In general, the path info will be a set of strings separated by slashes, so a request to /record.yaws/show/3141/5926 will have pathinfo set to show/3141/5926. This string should be split with re:split/3 and then used to show the correct data.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint