[web-devel] Type-safe URL handling

Curt Sampson cjs at starling-software.com
Tue Mar 16 14:56:09 EDT 2010


On Tue, Mar 16, 2010 at 9:51 AM, Gregory Collins <greg at gregorycollins.net>wrote:

> This rabbit hole goes pretty deep though; if you're serious about the
> bondage and discipline approach you'd want to ensure that you can
> check query parameters; i.e. "'/foo' takes a mandatory 'bar' integer
> parameter on the queryString and an optional 'sort' parameter which
> must be either 'asc' or 'desc'", etc.

Which is not at all unreasonable, actually, if you take the approach
I sorta-kinda-did with my Ruby system at one point (using regexps
to match URIs): if the URL doesn't match the types you need for
it, you get a 404. Thus, simplifying immensely for the sake of an
example, "/user/show/1312" shows information about user 1312, but
"/user/show/13x7" returns a 404.

You still have to deal with the problem somewhere else of making
sure everything within your system generates valid URLs, though....

cjs
-- 
Curt Sampson         <cjs at cynic.net        +81 90 7737 2974
             http://www.starling-software.com
The power of accurate observation is commonly called cynicism
by those who have not got it.    --George Bernard Shaw


More information about the web-devel mailing list