<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 21, 2013 at 9:08 AM, John Napiorkowski <span dir="ltr">&lt;<a href="mailto:jjn1056@yahoo.com" target="_blank">jjn1056@yahoo.com</a>&gt;</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">I&#39;d probably myself want some plack middleware that would convert<br>


<br>
/api/v1/account/&lt;id&gt;/widget/&lt;id&gt;<br>
<br>
<br>
to <br>
<br>
<br>
/account/&lt;id&gt;/widget/&lt;id&gt;    with accept type application/mycompany.v1+json<br></blockquote><div><br></div><div>I guess that would separate that out of the app. </div><div><br></div><div>I&#39;m currently using this approach in an app role:</div>

<div><br></div><div><div><div>    my @path_seg = split &#39;/&#39;, $c-&gt;req-&gt;path, -1;<br></div><div>    my $base_uri = $c-&gt;req-&gt;base;</div></div><div><br></div><div>    return unless @path_seg &amp;&amp; $path_seg[0] =~ /$path_prefix_version_regex/;</div>

<div><br></div><div>    my $match = $1;</div><div><br></div><div>    die &quot;path_prefix_version_regex ($path_prefix_version_regex) matched but failed to capture any value&quot;</div><div>        unless defined $match;</div>

<div><br></div><div>    $c-&gt;stash-&gt;{path_prefix_version} = $match;</div><div>    $base_uri-&gt;path( $base_uri-&gt;path . shift( @path_seg ) . &#39;/&#39; );</div></div><div><br></div><div><div>    # Force $req-&gt;path to reload _path next time $req-&gt;path is called.</div>

<div>    $c-&gt;req-&gt;_clear_path;</div></div><div><br></div><div><br></div><div> </div><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">


<br>
But you could probably support changing the URL path pretty easily with either setting the controller namespace to have v1 in it, or adding a root tot he change that specifies the new extra path part.<br></blockquote><div>

<br></div><div>But would that support it being an optional prefix?   Need both to work at the same time. </div><div><br></div><div><br></div><div> </div><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">

I understand the development word seems to prefer making version part of the path.  depending on your logic and the type of changes introduced it may or may not be easier to take one approach or the other.<br></blockquote>

<div><br></div><div>It does seem like that.   Deciding to go with the flow vs. doing it the &quot;right&quot; way is the decision to be made.   I like your suggestion to map it to an Accept header -- best of both worlds.</div>

<div> </div><div><br></div></div>-- <br>Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a>
</div></div>