JavaScript and Plane Fumes

Blog / Taffy 2.1.0 Released

Extree, extree, read all about it!

Taffy 2.1 is here! Another small, semi-frequent release. Since Taffy 2.0 in August, we've (yes, we, not I!) have fixed 5 bugs -- none too big, looks like 2.0 was a really stable release! -- and added 6 new features. As is the new custom, you can read the full release notes on GitHub.

The new feature I'm most excited about is that method metadata is now passed to onTaffyRequest. This enables neat stuff like adding role-based security as resource-function metadata:

Example Resource:

component extends="taffy.core.resource" taffy_uri="/foo" {
	function get() role="read-data" {
		//...
	}
}

Application.cfc:

function onTaffyRequest(verb, cfc, requestArguments, mimeExt, headers, methodMetadata){

	local.user = (...); //get user from token or something...

	if (structKeyExists(methodMetadata, "role")){
		for (var availableRole in local.user.roles){
			if (availableRole == methodMetadata.role) { return true; }
		}
		return newRepresentation().noData().withStatus(403, "Not Authorized");
	}else{
		//no role required on the method, so allow anyone to use it
		return true;
	}
}

Note the new 6th argument to onTaffyRequest: methodMetadata. You can call it whatever you like; arguments are passed positionally, not by name.


This release includes pull requests from Bill Rawlinson, Jean-Bernard van Zuylen, and Dominic OConnor. Thanks, guys!