<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.8.5">
</HEAD>
<BODY>
I am trying to write a middleware step that will modify the URL in a request before it gets to the default static request handler.  I can not find an example of how to do this.  What I have so far:<BR>
<BR>
execute( Req, Env ) -><BR>
    HostUrl = cowboy_req:host_url(Req),<BR>
    NewUrl = rewrite( HostUrl ),<BR>
    NewReq = ???<BR>
    {ok, NewReq, Env}.<BR>
<BR>
How do I modify a Request object so that it contains my modified URL, which cowboy_static will then process normally?  My 'rewrite' function converts logical directory names into real file-system paths, using a dynamic algorithm that can not be simply written into cowboy's dispatch rules.<BR>
<BR>
The dispatch rules I am using is as follows, where 'bz_libmap' is my module containing the code above:<BR>
            {"/music/[...]", cowboy_static, {dir, bz_libmap, ""}},<BR>
<BR>
</BODY>
</HTML>