Entries Tagged as Taffy

Recording for my CFMeetup presentation

If you weren't able to make it to my presentation last night on the Online ColdFusion User Group ("CFMeetup"), or if you just want to watch it again because it was that good, then you'll be interested to know that the recording is available online:

http://experts.adobeconnect.com/p39264326/

in REST | Speaking | Taffy | 3 Responses Posted 2011-04-01 08:00

Speaking for the Online ColdFusion Meetup 3/31

If you can't make it to cfObjective this year, or you just can't wait for my presentation, you can catch it in a few days when I present it on CFMeetup.

I'll be presenting on creating REST web services with ColdFusion, briefly covering other options (frameworks), and diving into my framework Taffy -- and especially covering things that are (going to be) new in Taffy 1.1, which I'm planning on releasing on the day of my presentation at cfObjective.

Of course, Taffy is open source, so you can go look at what I've been working on any time you like. Just note that the documentation is always the last thing to get updated, which is another way of saying that a lot has changed since I wrote the current docs.

While we're on the subject, I'm not sure when it will be released but I also recorded a brief interview for the CFHour podcast about REST in general and some teasers for my cfObjective session. (Special thanks to my dog for not barking his head off while we recorded!)

in ColdFusion | Speaking | Taffy | 1 Response Posted 2011-03-23 07:30

Setting Goals: Taffy Roadmap

I've told a few people recently that I would like to have Taffy 1.1 officially released at or before cfObjective, but I figured it was time to firm up some specific goals and put a date on it. To that end, I've put up a Roadmap with my target release date, and a list of completed and planned changes.

Taffy Roadmap

I heard from someone yesterday whose company is hesitant to use the bleeding edge release, and is still using the 1.0 release. Not that it was a bad build, but a lot has changed for the better, so I'm eager to get 1.1 done and released for people like these.

Here's hoping this plan comes together.

in Taffy | No Responses Yet Posted 2011-03-10 07:45

Presenting Taffy at Philly CFUG on 11/18

I will be presenting on my framework for writing REST web services, Taffy, at the Philadelphia ColdFusion User Group on Thursday, November 18th.

Here's a rough outline of what I plan to present:

  • Why should you write web services at all?
  • When and why should you choose REST over SOAP?
  • What are your options for writing REST with CF (pre-Taffy)?
  • What don't I like about those options?
  • What does Taffy do to alleviate these pains?
  • Demo: Building an API, one (Taffy) feature at a time

After the presentation, I'll update this post with my slides. Everything else you'll need (sample code, etc) is already posted on Github.

The location and other details are posted on the Philly CFUG blog. I hope to see you there!

in Speaking | Taffy | 4 Responses Posted 2010-11-09 12:15

Enforcing Limitations on your Taffy-powered API

You might be one of those people want to open up access to create, update, and delete your data via your API to the entire world with no restrictions; but it's not likely. A common need for APIs is defining and enforcing limitations such as API keys and authentication, rate limiting, logging, and so on.

Taffy provides a hook that allows you to allow or deny a request to continue, on a per-request basis, with onTaffyRequest.

When you define onTaffyRequest in your Application.cfc, it is called for each request and sent all of the information it needs to process the request:

  • HTTP Verb
  • Name of the CFC that would respond to the request
  • All request arguments, including tokens extracted from the URI and Query String/Put/Post parameters.
  • Requested Mime Type (json, xml, etc)
  • And (as of Taffy 1.1) a structure of the HTTP request headers

The default implementation, (when you don't override it) always returns TRUE; and, in the event that you would like to allow the request to continue so that your resources are allowed to do their thing, your implementation of onTaffyRequest should return TRUE as well.

If, on the other hand, you want to abort the request -- because login failed, or the customer owes you money, or they are over their rate limit (these are business rules and up to you to implement) -- then you should return a representation instance. This is just an instance of the object that serializes result data into the requested format, except in this case it will be used to tell the API consumer that, and hopefully why, their request is not allowed to continue.

Let's say that you're using the default representation class that comes with Taffy (capable of JSON serialization using ColdFusion's native SerializeJSON method), and you want to abort the current request:

function onTaffyRequest(verb, cfc, requestArguments, mimeExt, headers){
    var o = StructNew();
    if (/* customer owes you money */){
        o.msg = 'Your account is overdue. Please call Accounts Payable at 555-867-5309.';
        return newRepresentation().setData(o).withStatus(403);
    }
    //all checks passed, let the request continue
    return true;
}

The method newRepresentation will be available in Taffy 1.1; in the meantime, you will need to instantiate the representation object manually. If your default representation class is the Taffy default (taffy.core.genericRepresentation), then you would do so this way:

var r = createObject("component", "taffy.core.genericRepresentation");
return r.setData(o).withStatus(403);

Obviously, substitute your custom representation class cfc path there, if you're using a custom class; so that the result can be serialized to XML, or YAML, or whatever format it is that your API supports and the consumer is expecting their results to be in.

The status code I've used here is 403, which is the official HTTP Status Code for "Not Allowed". You should probably familiarize yourself with HTTP Status Codes, and maybe print it out and keep it handy. They are an important part in the way REST APIs work.

Doing all of this allows Taffy to respond to the request in a RESTful manner that the consumer software can understand (for example, as json/xml/etc) while still preventing unauthorized access.

in Taffy | No Responses Yet Posted 2010-10-18 08:00