On Mon, Oct 21, 2013 at 9:08 AM, John Napiorkowski <jjn1...@yahoo.com>wrote:
> I'd probably myself want some plack middleware that would convert > > /api/v1/account/<id>/widget/<id> > > > to > > > /account/<id>/widget/<id> with accept type application/mycompany.v1+json > I guess that would separate that out of the app. I'm currently using this approach in an app role: my @path_seg = split '/', $c->req->path, -1; my $base_uri = $c->req->base; return unless @path_seg && $path_seg[0] =~ /$path_prefix_version_regex/; my $match = $1; die "path_prefix_version_regex ($path_prefix_version_regex) matched but failed to capture any value" unless defined $match; $c->stash->{path_prefix_version} = $match; $base_uri->path( $base_uri->path . shift( @path_seg ) . '/' ); # Force $req->path to reload _path next time $req->path is called. $c->req->_clear_path; > > 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. > But would that support it being an optional prefix? Need both to work at the same time. > 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. > It does seem like that. Deciding to go with the flow vs. doing it the "right" way is the decision to be made. I like your suggestion to map it to an Accept header -- best of both worlds. -- Bill Moseley mose...@hank.org
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/