Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Better names for SCRIPT_NAME/PATH_INFO in a web framework?

by RonW (Parson)
on Dec 07, 2017 at 20:40 UTC ( #1205111=note: print w/replies, xml ) Need Help??


in reply to Better names for SCRIPT_NAME/PATH_INFO in a web framework?

script_name is the part of the path that matched current route, not the name of the script or the raw stuff from PSGI request.

I suggest route_name as this implies the value is a string rather than an object. Also, it emphasizes that it is the route and not the script.

path_info is anything that follows that matching part, for instance a wiki article name.

Even many years ago, I never liked path_info but it was the convention and I never thought of a better alternative. Even now, I'm not sure if there's a better name and it does fit with historical convention. Maybe route_params, but just params (or param) could be confusing. I'm not sure if there is a good enough alternative to justify not using the already familiar path_info (despite that I never liked the name).

Sometimes there are good reasons to not follow historical convention. Other times, not. Most cases, a minor change to convention is the better choice. Changing script_name to route_name falls under this 3rd category.

Replies are listed 'Best First'.
Re^2: Better names for SCRIPT_NAME/PATH_INFO in a web framework?
by Dallaylaen (Hermit) on Dec 07, 2017 at 20:59 UTC

    Thank you!

    route_name is definitely worth a shot. I'm also thinking about route_path, preparing ground for $request->route->path even though the latter is far, far ahead.

    route_param(s) evokes thoughts about the parameters of the route itself, not sure... Although I have a lot of other param's there, so one more won't hurt...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1205111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2019-05-25 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (152 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!