234 attempt to fix js error Uncaught SyntaxError: Unexpected identifier 'hidden'
This commit is contained in:
+20
-20
@@ -12,7 +12,7 @@ The REST Web Service framework for ColdFusion and Railo
|
||||
|
||||
**Application.cfc:**
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
component extends="taffy.core.api" {}
|
||||
```
|
||||
|
||||
@@ -24,7 +24,7 @@ component extends="taffy.core.api" {}
|
||||
|
||||
**/resources/hello.cfc:**
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
component extends="taffy.core.resource" taffy_uri="/hello" {
|
||||
|
||||
function get(){
|
||||
@@ -77,13 +77,13 @@ You can see that the taffy folder is a sibling to Application.cfc. This allows A
|
||||
|
||||
Next, if your Application.cfc and `/resources/` folder aren't in the web-root (e.g. they're inside something like `/api/`) then you'll need to add an [application-specific mapping](http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=appFramework_04.html) for `/resources` so that Taffy can find your resources to initialize the routes.
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
this.mappings["/resources"] = expandPath("./resources");
|
||||
```
|
||||
|
||||
You'll also need to add a mapping for `/taffy` so that the resources can extend `taffy.core.resource` (since the taffy folder isn't a child of the resources folder):
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
this.mappings["/taffy"] = expandPath("./taffy");
|
||||
```
|
||||
|
||||
@@ -101,7 +101,7 @@ Implementing OAuth is something I would like to document, but it is a fairly lar
|
||||
|
||||
Taffy allows for setting the HTTP status message using [.withStatus()](#withstatus), such as:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return representationOf({...}).withStatus(403, "Not Authorized");
|
||||
```
|
||||
|
||||
@@ -148,7 +148,7 @@ The **taffy:uri** property applies to the `<cfcomponent>` tag or the `component{
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
component taffy_uri="/artist/{artistId}" {
|
||||
}
|
||||
```
|
||||
@@ -179,7 +179,7 @@ By convention, resources will automatically map the 4 primary HTTP REST verbs --
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
function getUser( numeric userId ) taffy_verb="get" {
|
||||
}
|
||||
```
|
||||
@@ -199,7 +199,7 @@ By convention, the mime-types supported by your API are determined by the method
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
function getAsJson() taffy_mime="application/json" {
|
||||
}
|
||||
```
|
||||
@@ -218,7 +218,7 @@ When your API supports more than one data format (i.e. json and xml), you must s
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
function getAsJson() taffy_mime="application/json" taffy_default="true" {}
|
||||
|
||||
function getAsXml() taffy_mime="application/xml" {}
|
||||
@@ -228,7 +228,7 @@ function getAsXml() taffy_mime="application/xml" {}
|
||||
|
||||
Default values:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
variables.framework = {
|
||||
reloadKey = "reload",
|
||||
reloadPassword = "true",
|
||||
@@ -453,7 +453,7 @@ Taffy calls this method during initialization to determine in which configured e
|
||||
|
||||
The returned value will be used to load environment-specific configuration. For example, if you have the following code in your Application.cfc, then the dashboard will be disabled in production:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
variables.framework = {
|
||||
|
||||
disableDashboard = false
|
||||
@@ -488,13 +488,13 @@ This method is optional, and allows you to inspect and potentially abort an API
|
||||
|
||||
If you do not return TRUE, allowing the request to continue as normal, then Taffy expects you to return a **[representation](/atuttle/Taffy/wiki/Using-a-Custom-Representation-Class)** (either the default class, or a custom one) that it should immediately return to the consumer, serialized to the appropriate format. If you simply want to return with a status code of 403 (which indicates "Not Allowed"), you could do this:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return newRepresentation().noData().withStatus(403);
|
||||
```
|
||||
|
||||
Alternately, you could return some data to indicate that they owe you money or something:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return newRepresentation()
|
||||
.setData({error="Your account is past due. Please email accounts payable."})
|
||||
.withStatus(403);
|
||||
@@ -504,7 +504,7 @@ The options here are limited only by your imagination.
|
||||
|
||||
You can add data to the **requestArguments** structure and this will be passed on to any resource that handles the request. Simply add a key to the structure:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
function onTaffyRequest(verb, cfc, requestArguments, mimeExt, headers) {
|
||||
arguments.requestArguments.myData = "myvalue";
|
||||
return true;
|
||||
@@ -513,7 +513,7 @@ function onTaffyRequest(verb, cfc, requestArguments, mimeExt, headers) {
|
||||
|
||||
In your resource:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
function get(myData) {
|
||||
//arguments.myData = myValue
|
||||
}
|
||||
@@ -530,7 +530,7 @@ Resource CFCs extend `taffy.core.resource`. The following methods are available
|
||||
|
||||
This method allows you to specify that there is no data to be returned for the current request. Generally, you would use it in conjunction with the **withStatus** method to set a specific return status for the request. For example, if the requested resource doesn't exist, you could return a 404 error like so:
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return noData().withStatus(404);
|
||||
```
|
||||
|
||||
@@ -543,7 +543,7 @@ return noData().withStatus(404);
|
||||
|
||||
This method transforms a ColdFusion query object into an array of structures. It was added because ColdFusion's serializeJSON functionality uses an ..._eccentric_... format for queries. **queryToArray** returns the format most people expect: a vanilla array of structures with named keys. To be fair the ACF serialization format uses less data as long as there is more than 1 row in the query, but it doesn't matter that you do a better job if nobody understands your output. _queryToArray also preserves query column name case, which serializeJSON does not._
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return representationOf(queryToArray(someQuery));
|
||||
```
|
||||
|
||||
@@ -603,7 +603,7 @@ Use this method in place of `representationOf()` to stream an image from disk (o
|
||||
|
||||
This special method _**requires**_ the use of either **noData** or **representationOf**. It adds custom headers to the return. Additional use of **withStatus** optional.
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return representationOf(myData).withHeaders({"X-POWERED-BY"="Taffy 2.0!"});
|
||||
```
|
||||
|
||||
@@ -616,7 +616,7 @@ return representationOf(myData).withHeaders({"X-POWERED-BY"="Taffy 2.0!"});
|
||||
|
||||
This special method _**requires**_ the use of either **streamFile** or **streamBinary**. It overrides the default mime type header for the return.
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return streamFile("kittens/cuteness.pdf").withMime("application/pdf");
|
||||
```
|
||||
|
||||
@@ -632,7 +632,7 @@ This special method _**requires**_ the use of either **noData** or **representat
|
||||
|
||||
_If you do not specify a return status code, Taffy will always return status code 200 (OK) by default._
|
||||
|
||||
```js
|
||||
```cfscript
|
||||
return noData().withStatus(404, "Not Found");
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user