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

</tt>