<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 12, 2015 at 5:38 PM, Imants Cekusins <span dir="ltr"><<a href="mailto:imantc@gmail.com" target="_blank">imantc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">> A rewriter exports arg_rewrite/1, not out/1,<br>
<br>
</span>ta, Steve.<br>
<br>
btw  arg_rewrite output spec format:<br>
<br>
Arg#arg{<br>
 state = #rewrite_response{  }<br>
}<br>
<br>
is documented @<br>
<br>
<a href="https://github.com/klacke/yaws/blob/master/test/t2/rewritetest.erl" target="_blank">https://github.com/klacke/yaws/blob/master/test/t2/rewritetest.erl</a><br>
<br>
I should have checked.<br></blockquote><div><br></div><div>That's a test for the feature, but you can find documentation here: <a href="http://yaws.hyber.org/yaws.pdf">http://yaws.hyber.org/yaws.pdf</a></div><div><br></div><div>BTW I now realize why your example called yapp:out(Arg1): the OP uses yapps, so his arg_rewrite_mod setting will already be set to yapp, so my example needs to take that into account too. It should be the following instead:</div><div><br></div><div><div>-module(methods_rewriter).</div><div>-export([arg_rewrite/1]).</div><div><br></div><div>-include_lib("yaws_api.hrl").</div><div><br></div><div>arg_rewrite(Arg) -></div><div>    Allowed = ['GET', 'POST'],</div><div>    Req = yaws_api:arg_req(Arg),</div><div>    Method = yaws_api:http_request_method(Req),</div><div>    case lists:member(Method, Allowed) of</div><div>        true -></div><div>            yapp:arg_rewrite(Arg);</div><div>        false -></div><div>            AllowedStrs = string:join([atom_to_list(M) || M <- Allowed], ","),</div><div>            Arg#arg{state=</div><div>                        #rewrite_response{</div><div>                           status=405,</div><div>                           headers=[{header, {"Allow", AllowedStrs}},</div><div>                                    {header, {connection, "close"}}]}}</div><div>    end.</div></div><div><br></div><div>The difference is that when the method is allowed, we call yapp:arg_rewrite/1 instead of just returning Arg.</div><div><br></div><div>--steve</div></div></div></div>