diff --git a/core/api.cfc b/core/api.cfc index b2456ae1..89ad59e5 100644 --- a/core/api.cfc +++ b/core/api.cfc @@ -54,7 +54,7 @@ - + @@ -161,8 +161,8 @@ - @@ -280,6 +280,7 @@ + @@ -344,11 +345,11 @@

Taffy is up and running!

-

It looks like you don't have any resources defined. Get started by creating the folder +

It looks like you don't have any resources defined. Get started by creating the folder #guessResourcesFullPath()# in which you should place your Resource CFC's.

-

Or you could set up a bean factory, like ColdSpring - or DI/1. Want to know more about using bean factories with Taffy? +

Or you could set up a bean factory, like ColdSpring + or DI/1. Want to know more about using bean factories with Taffy? Check out the wiki!

If all else fails, I recommend starting with Getting Started.

@@ -373,8 +374,17 @@ Actual desired method will be contained in a special header ---> + + + + + + + + + + - diff --git a/core/factory.cfc b/core/factory.cfc index 6a03170a..8ae4a37e 100644 --- a/core/factory.cfc +++ b/core/factory.cfc @@ -70,18 +70,18 @@ -
- function submitRequest( verb, resource, representation ){ - var endpoint = window.location.protocol + '//#cgi.server_name#'; + var url = window.location.protocol + '//#cgi.server_name#'; + var endpointURLParam = '#jsStringFormat(application._taffy.settings.endpointURLParam)#'; + var endpoint = resource.split('?')[0]; + var args = ''; + if (window.location.port != 80){ - endpoint += ':' + window.location.port; + url += ':' + window.location.port; + } + url += '#cgi.SCRIPT_NAME#'; + + if( resource.indexOf('?') && resource.split('?')[1] ){ + args = resource.split('?')[1]; } - endpoint += '#cgi.SCRIPT_NAME#'; - var url = endpoint + resource; - var dType = null; - if (representation && representation.indexOf("{") == 0){ - dType = "application/json"; + + if( representation && representation.indexOf('{') == 0 ){ + representation = $.parseJSON(representation); + representation[endpointURLParam] = endpoint; + } else { + representation = endpointURLParam + '=' + encodeURIComponent(endpoint); + + if( args ){ representation += '&' + args; } } + $("#rest_body").hide(); $.ajax({ type: verb, url: url, cache: false, data: representation, - contentType: dType, success: function(data, status, xhr){ $("#headers").val(xhr.getAllResponseHeaders()); $("#statuscode").val(xhr.status + " " + xhr.statusText).removeClass("statusError").addClass("statusSuccess"); diff --git a/tests/Application.cfc b/tests/Application.cfc index aac131e9..a4304c5f 100644 --- a/tests/Application.cfc +++ b/tests/Application.cfc @@ -1,6 +1,8 @@ this.name = "Taffy_testSuite"; + this.mappings['/resources'] = '#getDirectoryFromPath(getCurrentTemplatePath())#resources'; + this.mappings['/resourcesError'] = '#getDirectoryFromPath(getCurrentTemplatePath())#resourcesError'; variables.framework = {}; variables.framework.disableDashboard = false; diff --git a/tests/tests/Application.cfc b/tests/tests/Application.cfc new file mode 100644 index 00000000..70a1e2ee --- /dev/null +++ b/tests/tests/Application.cfc @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tests/TestCore.cfc b/tests/tests/TestCore.cfc index 3e49f581..a8c8b9a8 100644 --- a/tests/tests/TestCore.cfc +++ b/tests/tests/TestCore.cfc @@ -1,7 +1,6 @@ - function beforeTests(){ variables.taffy = createObject("component","taffy.tests.Application"); variables.factory = variables.taffy.getBeanFactory(); @@ -405,6 +404,33 @@ assertEquals( "dontpanic", application._taffy.settings.reloadPassword ); } + function use_endpointURLParam_in_GET(){ + local.result = apiCall('get','?#application._taffy.settings.endpointURLParam#=/echo/2606.json',''); + + debug(local.result); + assertEquals(999,val(local.result.statusCode)); + } + + function use_endpointURLParam_in_POST(){ + local.result = apiCall('post','?#application._taffy.settings.endpointURLParam#=/echo/2606.json','bar=foo'); + + debug(local.result); + assertEquals(200,val(local.result.statusCode)); + } + + function use_endpointURLParam_in_PUT(){ + local.result = apiCall('put','?#application._taffy.settings.endpointURLParam#=/echo/2606.json','bar=foo'); + + debug(local.result); + assertEquals(200,val(local.result.statusCode)); + } + + function use_endpointURLParam_in_DELETE(){ + local.result = apiCall('delete','?#application._taffy.settings.endpointURLParam#=/echo/tunnel/2606.json',''); + + debug(local.result); + assertEquals(200,val(local.result.statusCode)); + } diff --git a/tests/tests/TestFactory.cfc b/tests/tests/TestFactory.cfc index b05447a9..0cc39c53 100644 --- a/tests/tests/TestFactory.cfc +++ b/tests/tests/TestFactory.cfc @@ -55,7 +55,7 @@ assertTrue(structKeyExists(application._taffy.status, "skippedResources")); assertTrue( arrayLen(application._taffy.status.skippedResources) gt 0 ); - variables.factory.loadBeansFromPath( '/taffy/tests/resources', 'taffy.tests.resources', expandPath('taffy/tests/resources'), true ); + variables.factory.loadBeansFromPath( expandPath('/taffy/tests/resources'), 'taffy.tests.resources', expandPath('/taffy/tests/resources'), true ); debug(application._taffy.status); assertTrue(structKeyExists(application._taffy.status, "skippedResources")); assertTrue( ArrayLen(application._taffy.status.skippedResources) eq 0, "Expected skipped resources array to be empty but it wasn't" ); diff --git a/tests/tests/base.cfc b/tests/tests/base.cfc index c37c1df0..3153344c 100644 --- a/tests/tests/base.cfc +++ b/tests/tests/base.cfc @@ -8,13 +8,15 @@ + + - + - + @@ -28,7 +30,7 @@ - + @@ -37,7 +39,12 @@ - + + + + + +