Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by RonW (Parson)
on Dec 07, 2017 at 20:40 UTC ( [id://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 (Chaplain) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1205111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found