Posts tagged with “REST”
- All (3)
- Entries (1)
- Links (2)
- Photos (0)
CodeIgniter REST
A nice look at how to implement REST routes in CodeIgniter. I’ve been using CodeIgniter for a recent project, and I definitely wish I had found this before starting.
ObjectiveResource
Pretty cool:
ObjectiveResource is an Objective-C port of Ruby on Rails’ ActiveResource. It provides a way to serialize objects to and from Rails’ standard RESTful web-services (via XML or JSON) and handles much of the complexity involved with invoking web-services of any language from the iPhone.
I’ve been considering trying out some iPhone development (even though I don’t yet own one), and this seems like a really slick way to interface with an existing Rails application.
RESTfully Forward Users to FeedBurner in Rails
After launching my new site, I realized I had forgotten to use FeedBurner to track my RSS feed subscribers. Because FeedBurner requires that you forward users to your feed on their servers, I needed a way to forward users along, but I also wanted to make sure that if FeedBurner’s spider came to the same feed URL, they would be served the source RSS instead of being forwarded. My solution ended up like this:
class NotebooksController < ApplicationController
def show
respond_to do |format|
format.html
format.rss do
unless request.env['HTTP_USER_AGENT'] =~ /feedburner/i
redirect_to 'http://feeds.feedburner.com/KyleSlattery'
end
end
end
end
end
If you take a close look at the, all I’m doing is checking the user agent of the request, and unless it’s FeedBurner, I redirect the user to the “burned” feed. If it is FeedBurner, things go ahead normally, and the RSS feed gets rendered.
This means that instead of creating separate actions, one that forwards to FeedBurner, and one that renders the RSS, I just have one action/URL that does both: http://kyleslattery.com/notebook.rss. So far, it’s worked great, and doing it this way really helped to keep my code clean and RESTful.
