Perl::Dancer how to include a file path as a parameter in the URI -
i'm new dancer framework , web apps in general. have dancer project in have route accepts multiple parameters. far, no sweat. however, if 1 of parameters has file path value route not found.
i have tried encoding parameter string follows eliminate forward slashes:
$paramstring =~ s/\//%2f/g;
and encode slashes expected (i print out in log make sure).
however, after parameter string appended base uri route i'm interested in, uri shows in browser in unencoded form, 404 error raised , log says unencoded route can't found.
i looked request.pm module , found in init method private method called _url_decode called removes encoding. there way disable when not desired?
i tried using uri_for method create uri. in case, encoded uri show in browser, however, route still not found , log indicates unencoded form (with forward slashes) being used search route
trying match 'get /exome_proj_config/project_type=exome&project_root=/usr/local/projects/users/pdagosto/projects&analysis_project_name=test' against /^\/exome_proj_config\/([^\/]+)$/ (generated '/exome_proj_config/:project_type:project_root:analysis_project_name') in /home/pdagosto/perl5/lib/perl5/dancer/route.pm l. 84 here
since regex used match looking string without forward slashes following 1 @ end of base uri it's clear route never found.
is there way have uri parameter contains path or must other approach used?
it possible have uri file path or slashes in parameter provided parameter part of query string rather path. (see http://en.wikipedia.org/wiki/uniform_resource_locator.)
for example see dancer script:
use strict; use warnings; use dancer; '/file/action/:action' => sub { $filename = param('filename'); $action = param('action'); return "filename $filename , action $action"; }; dance;
if put string browser
http://localhost:3000/file/action/delete?filename=/folder/filename.txt
then should expect see this:
filename /folder/filename.txt , action delete
in question url show uses & character separate parameters looks need ? character first separate query string path. unclear question how creating requests - provided can put filename in query string part of url approach above should work.
Comments
Post a Comment