blob: 7783cc7412013f1813ab9883c9b7f58c636c5034 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<tt>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN"><br>
<HTML><br>
<HEAD><br>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8"><br>
<META NAME="GENERATOR" CONTENT="GtkHTML/4.8.5"><br>
</HEAD><br>
<BODY><br>
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>
<BR><br>
execute( Req, Env ) -><BR><br>
HostUrl = cowboy_req:host_url(Req),<BR><br>
NewUrl = rewrite( HostUrl ),<BR><br>
NewReq = ???<BR><br>
{ok, NewReq, Env}.<BR><br>
<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>
<BR><br>
The dispatch rules I am using is as follows, where 'bz_libmap' is my module containing the code above:<BR><br>
{"/music/[...]", cowboy_static, {dir, bz_libmap, ""}},<BR><br>
<BR><br>
</BODY><br>
</HTML><br>
</tt>
|