initial
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
RewriteEngine On
|
||||
|
||||
#if we've already been rewritten to use index.cfm/* format, don't make a circular request
|
||||
RewriteRule index\.cfm/* - [L]
|
||||
|
||||
RewriteRule ^(.*)$ index.cfm/$1
|
||||
@@ -0,0 +1,30 @@
|
||||
<cfcomponent extends="taffy.core.api">
|
||||
<cfscript>
|
||||
|
||||
this.name = hash(getCurrentTemplatePath());
|
||||
|
||||
this.mappings["/resources"] = listDeleteAt(cgi.script_name, listLen(cgi.script_name, "/"), "/") & "/resources";
|
||||
|
||||
variables.framework = {};
|
||||
variables.framework.debugKey = "debug";
|
||||
variables.framework.reloadKey = "reload";
|
||||
variables.framework.reloadPassword = "true";
|
||||
variables.framework.serializer = "taffy.core.nativeJsonSerializer";
|
||||
variables.framework.returnExceptionsAsJson = true;
|
||||
|
||||
function onApplicationStart(){
|
||||
return super.onApplicationStart();
|
||||
}
|
||||
|
||||
function onRequestStart(TARGETPATH){
|
||||
return super.onRequestStart(TARGETPATH);
|
||||
}
|
||||
|
||||
// this function is called after the request has been parsed and all request details are known
|
||||
function onTaffyRequest(verb, cfc, requestArguments, mimeExt){
|
||||
// this would be a good place for you to check API key validity and other non-resource-specific validation
|
||||
return true;
|
||||
}
|
||||
|
||||
</cfscript>
|
||||
</cfcomponent>
|
||||
@@ -0,0 +1,6 @@
|
||||
<!---
|
||||
DO NOT DELETE THIS FILE
|
||||
===============================
|
||||
This file is necessary for Taffy to work, but should be blank.
|
||||
All requests funnel through it, but are handled by framework internal functionality.
|
||||
--->
|
||||
@@ -0,0 +1,24 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy_uri="/artist/{artistId}/art/{artId}">
|
||||
|
||||
<cfset variables.dummyData = StructNew() />
|
||||
<cfset variables.dummyData.whatever = true />
|
||||
<cfset variables.dummyData.phone = encode.string(5558675309) />
|
||||
<cfset variables.dummyData.phoneNumeric = 5558675309 />
|
||||
|
||||
<cffunction name="get" access="public" output="false">
|
||||
<cfreturn representationOf(variables.dummyData).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="post" access="public" output="false">
|
||||
<cfreturn representationOf(variables.dummyData).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="put" access="public" output="false">
|
||||
<cfreturn representationOf(variables.dummyData).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="delete" access="public" output="false">
|
||||
<cfreturn representationOf(variables.dummyData).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
</cfcomponent>
|
||||
@@ -0,0 +1,84 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy:uri="/artist/{id}" hint="some hint about this resource">
|
||||
|
||||
<cffunction name="get" access="public" output="false">
|
||||
<cfargument name="id" type="numeric" required="true" />
|
||||
<cfset var q = ""/>
|
||||
<cfset var col = "" />
|
||||
<cfset var rtn = StructNew() />
|
||||
<cfquery name="q" datasource="cfartgallery">
|
||||
select * from artists where artistId = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.id#" />
|
||||
</cfquery>
|
||||
<cfif q.recordCount gt 0>
|
||||
<cfloop list="#q.ColumnList#" index="col">
|
||||
<cfset rtn[col] = q[col][1] />
|
||||
</cfloop>
|
||||
<cfreturn representationOf(rtn).withStatus(200) />
|
||||
<cfelse>
|
||||
<cfreturn noData().withStatus(404) />
|
||||
</cfif>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="put" access="public" output="false">
|
||||
<cfargument name="id" type="numeric" required="true" />
|
||||
<cfargument name="firstname" type="string" required="false" default="" />
|
||||
<cfargument name="lastname" type="string" required="false" default="" />
|
||||
<cfargument name="address" type="string" required="false" default="" hint="some hint about this parameter" />
|
||||
<cfargument name="city" type="string" required="false" default="" />
|
||||
<cfargument name="state" type="string" required="false" default="" />
|
||||
<cfargument name="postalcode" type="string" required="false" default="" />
|
||||
<cfargument name="email" type="string" required="false" default="" />
|
||||
<cfargument name="phone" type="string" required="false" default="" />
|
||||
<cfargument name="fax" type="string" required="false" default="" />
|
||||
<cfargument name="thepassword" type="string" required="false" default="" />
|
||||
<cfset var q = "" />
|
||||
<cfquery name="q" datasource="cfartgallery">
|
||||
update artists
|
||||
set artistid=artistid
|
||||
<cfif len(arguments.firstname)>
|
||||
,firstname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstname#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.lastname)>
|
||||
,lastname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastname#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.address)>
|
||||
,address = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.address#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.city)>
|
||||
,city = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.city#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.state)>
|
||||
,state = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.state#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.postalcode)>
|
||||
,postalcode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.postalcode#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.email)>
|
||||
,email = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.phone)>
|
||||
,phone = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.phone#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.fax)>
|
||||
,fax = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fax#" />
|
||||
</cfif>
|
||||
<cfif len(arguments.thepassword)>
|
||||
,thepassword = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.thepassword#" />
|
||||
</cfif>
|
||||
where artistid = <cfqueryparam cfsqltype="cf_sql_numeric" value="#arguments.id#" />
|
||||
</cfquery>
|
||||
<cfreturn noData().withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="delete" access="public" output="false">
|
||||
<cfargument name="id" type="numeric" required="true" />
|
||||
<cfset var q = "" />
|
||||
<cfquery name="q" datasource="cfartgallery">
|
||||
delete from artists where artistid = <cfqueryparam cfsqltype="cf_sql_numeric" value="#arguments.id#" />
|
||||
</cfquery>
|
||||
<cfreturn noData().withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="someInternalMethod" hint="you should not see this documentation...">
|
||||
</cffunction>
|
||||
|
||||
</cfcomponent>
|
||||
@@ -0,0 +1,15 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy:uri="/artist/{artistId}/art" hint="Collection of art data">
|
||||
|
||||
<cfset variables.dummyData = StructNew() />
|
||||
<cfset variables.dummyData.whatever = true />
|
||||
|
||||
<cffunction name="get" access="public" output="false" hint="Get some collection of art data">
|
||||
<cfargument name="artistId" type="numeric" required="true" />
|
||||
<cfreturn representationOf(variables.dummyData).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="post" access="public" output="false" hint="Insert a new art record">
|
||||
<cfreturn representationOf(variables.dummyData).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
</cfcomponent>
|
||||
@@ -0,0 +1,59 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy_uri="/artists">
|
||||
|
||||
<cffunction name="get" access="public" output="false">
|
||||
<cfset var q = "" />
|
||||
<cfquery name="q" datasource="cfartgallery">
|
||||
select * from artists
|
||||
</cfquery>
|
||||
<cfreturn representationOf(q).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="post" access="public" output="false">
|
||||
<cfargument name="firstname" type="string" required="false" default="" />
|
||||
<cfargument name="lastname" type="string" required="false" default="" />
|
||||
<cfargument name="address" type="string" required="false" default="" />
|
||||
<cfargument name="city" type="string" required="false" default="" />
|
||||
<cfargument name="state" type="string" required="false" default="" />
|
||||
<cfargument name="postalcode" type="string" required="false" default="" />
|
||||
<cfargument name="email" type="string" required="false" default="" />
|
||||
<cfargument name="phone" type="string" required="false" default="" />
|
||||
<cfargument name="fax" type="string" required="false" default="" />
|
||||
<cfargument name="thepassword" type="string" required="false" default="" />
|
||||
<cfset var q = "" />
|
||||
<cfquery name="q" datasource="cfartgallery">
|
||||
insert into artists (firstname,lastname,address,city,state,postalcode,email,phone,fax,thepassword)
|
||||
values (
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstname#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastname#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.address#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.city#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.state#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.postalcode#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.phone#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fax#" />,
|
||||
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.thepassword#" />
|
||||
)
|
||||
</cfquery>
|
||||
<cfquery name="q" datasource="cfartgallery">
|
||||
select * from artists
|
||||
where
|
||||
firstname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstname#" />
|
||||
and lastname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastname#" />
|
||||
and address = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.address#" />
|
||||
and city = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.city#" />
|
||||
and state = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.state#" />
|
||||
and postalcode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.postalcode#" />
|
||||
and email = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />
|
||||
and phone = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.phone#" />
|
||||
and fax = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fax#" />
|
||||
and thepassword = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.thepassword#" />
|
||||
</cfquery>
|
||||
<cfreturn representationOf(q).withStatus(200) />
|
||||
</cffunction>
|
||||
|
||||
<!---
|
||||
The DELETE and PUT verbs are not implemented, so those actions are not permitted.
|
||||
--->
|
||||
|
||||
</cfcomponent>
|
||||
Reference in New Issue
Block a user