Hi Tim,
You've got a couple of missteps in your code, here.
For starters, your URI should probably not end with a slash: taffy:uri="/pdf" -- though I doubt this is causing you any problems at the moment.
Then, you have to send data in a format that Taffy can handle. Out of the box, that means just JSON. You could very easily add a "text/html" deserializer that takes the body input and puts it into the "data" argument you provide... But let's step back for a second and look at how input data is handled in the usual (JSON) scenario.
A POST is done with a body something like: { "foo": 1, "bar": 2 }
Taffy will automatically deserialize this and then map those two body arguments, foo and bar, to the resource method's arguments:
function post( foo, bar ){}
Now, let's look at your method:
function post( data ){...}
Taffy needs to know how to get from the request's body to { "data": ? }. That's what you can do in your deserializer.
I'm just writing this in my email, not testing as I go, so it may have some bugs, but here's a guess at the deserializer you need to write:
component extends="taffy.core.baseDeserializer" {
function getFromHTML( body ) output="false" taffy:mime="text/html" {
return { data: body };
}
}
You can get more info on writing a custom Deserializer
here.
So that should get your input into the resource method, but sending a file back to the client is not quite as easy as you've written. Instead of the usual
return representationOf( data here ); method of sending response data back to the client, you'll want to use
return streamFile(...);
Hope that helps!
Adam