RESTful Typo

So, I’ve finally got around to reading up on the workings of the
Simply RESTful additions to Edge rails and I think I am in love.

The first time I saw Rails, not long after it was announced as it
happens, I looked at the standard URL forms and thought “Ick! That’s
not very RESTful”. Then when Typo came along and I started hacking, I
tended to hold my nose slightly as I contemplated the default routes.

I spy some routes.rb rejiggery in the near future. My goal is to
continue to support the following permaURLs, but they will no longer
be canonical:

articles/:year/:month/:day/:title
articles/:year/:month/:day

xml/itunes/feed.xml
xml/articlerss/:id/feed.xml # Probably a redirect to ‘articles/:id’,
:format => ‘xml’
xml/commentrss/feed.xml => comments/index.xml
xml/trackbackrss/feed.xml => trackbacks/index.xml
xml/:format/feed.xml => articles/index.xml;format
xml/:format/:type/feed.xml => :type/index.xml;format

Etc.

The translation to RESTful URLs should be relatively
straightforward. At the moment, it looks like the biggest change would
be to the admin URLs. For instance admin/content would become
articles/index;admin (which so wouldn’t be cached).

The power of RESTful URLs becomes apparent when you consider page
caching. One of the problems we had with page caching before was that
the webserver didn’t take query strings into account when doing page
lookups, and that caused all sorts of headaches. Even without page
caching I think we’re going to be able to neaten up the fragment
caching, which is no bad thing.

Thoughts?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 21/08/2006, at 20:54 PM, Piers C. wrote:

The translation to RESTful URLs should be relatively
straightforward. At the moment, it looks like the biggest change would
be to the admin URLs. For instance admin/content would become
articles/index;admin (which so wouldn’t be cached).

Whatever you do, don’t make it too hard for those of us who use URL
rewriting to force all admin to go via HTTPS. At the moment, my
pattern is more or less just “^/(admin|accounts)/.*” and I kinda like
the simplicity.

If the new admin URLs all reliably end in “;admin” then the pattern
should be just as simple. Much more diversion from that would start
to become difficult. :slight_smile:

TX

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFE6anGuMe8iwN+6nMRAsoSAKCLz4986uNegzWX0fJKWXVHW+06rACfbwZB
T9LyGVFRWLLLBQGXjml9ymM=
=QiM1
-----END PGP SIGNATURE-----

Trejkaz [email protected] writes:

the simplicity.

If the new admin URLs all reliably end in “;admin” then the pattern
should be just as simple. Much more diversion from that would start
to become difficult. :slight_smile:

I can’t promise they’ll reliably end in admin I’m afraid. However,
it shouldn’t be beyond the bounds of possibility to tweak the ‘require
authentication’ filter to redirect http URLs to https ones. Probably
an environment.rb configuration, and definitely the neater solution.

“Scott L.” [email protected] writes:

I’m not completely sure that I see the point in switching URL formats.
I actually like our permalink URLs, and frequently use
article/:year/:month to view a subset of the blog. I may be in the
minority on this, though :-).

I can see moving to restful URLs for API-ish code like the feeds (and
then mirroring them with PUT, DELETE, to replace the admin interface),
but it’s not clear to me that more restful permalink URLs really
achieves any particular goal. Can you give a couple examples?

As we discussed on GTalk, I think we can keep the current permalink
URLs by introducing a ‘posts’ controller for the more APIish ways of
monkeying with things.

As an aside, I wonder if going RESTful would make implementing the
Atom API any easier?

On 8/21/06, Piers C. [email protected] wrote:

rewriting to force all admin to go via HTTPS. At the moment, my
an environment.rb configuration, and definitely the neater solution.
I’m not completely sure that I see the point in switching URL formats.
I actually like our permalink URLs, and frequently use
article/:year/:month to view a subset of the blog. I may be in the
minority on this, though :-).

I can see moving to restful URLs for API-ish code like the feeds (and
then mirroring them with PUT, DELETE, to replace the admin interface),
but it’s not clear to me that more restful permalink URLs really
achieves any particular goal. Can you give a couple examples?

Scott

I can’t promise they’ll reliably end in admin I’m afraid. However,
it shouldn’t be beyond the bounds of possibility to tweak the ‘require
authentication’ filter to redirect http URLs to https ones. Probably
an environment.rb configuration, and definitely the neater solution.

Yeah, agreed. I wouldn’t even need a single line of Apache
configuration
then, and I suppose it would make the trick work on multiple web servers
while only having to write the redirection code once. :slight_smile:

TX

Piers C. wrote:

As we discussed on GTalk, I think we can keep the current permalink
URLs by introducing a ‘posts’ controller for the more APIish ways of
monkeying with things.

As an aside, I wonder if going RESTful would make implementing the
Atom API any easier?

I really like Scott R.'s writeup of how moving IconBuffet to REST
saved him a bunch of code.

http://scottraymond.net/articles/2006/07/20/refactoring-to-rest

If you can create a set of URLs that represent the same sets of
resources
as the Atom API, I imagine that would be very useful for implementing
the
Atom API.

–josh

“Trejkaz” [email protected] writes:

I can’t promise they’ll reliably end in admin I’m afraid. However,
it shouldn’t be beyond the bounds of possibility to tweak the ‘require
authentication’ filter to redirect http URLs to https ones. Probably
an environment.rb configuration, and definitely the neater solution.

Yeah, agreed. I wouldn’t even need a single line of Apache configuration
then, and I suppose it would make the trick work on multiple web servers
while only having to write the redirection code once. :slight_smile:

Oh, that’s easy. We already have a redirection controller.

On 8/22/06, Piers C. [email protected] wrote:

Oh, that’s easy. We already have a redirection controller.
Yeah. Typo’s least-used feature :-).

Scott

[email protected] writes:

achieves any particular goal. Can you give a couple examples?

http://scottraymond.net/articles/2006/07/20/refactoring-to-rest

Oh yes. One of the things I read that reminded me that Rails is doing
the Right Thing now.

If you can create a set of URLs that represent the same sets of resources
as the Atom API, I imagine that would be very useful for implementing the
Atom API.

It’s certainly tempting :slight_smile: