Created
April 25, 2014 10:30
-
-
Save adamcameron/11284877 to your computer and use it in GitHub Desktop.
Example usage of http://javascript-minifier.com/raw via CFML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
param name="URL.sourceFile"; | |
param name="URL.destinationFile"; | |
if (!fileExists(URL.sourceFile)){ | |
throw(type="FileNotFoundException", message="Source file not found", detail="The source file - #URL.sourceFile# - was not found"); | |
} | |
httpResponse = new Http( | |
URL = "http://javascript-minifier.com/raw", | |
method = "POST", | |
parameters = [{type="formfield", name="input", value=fileRead(URL.sourceFile, "UTF-8")}] | |
).send().getPrefix(); | |
if (httpResponse.statusCode != "200 OK"){ | |
throw(type="FailedRequestException", message="The web service request failed", detail="The request failed with a response of #httpResponse.statusCode#"); | |
} | |
fileWrite(URL.destinationFile, httpResponse.fileContent, "UTF-8"); | |
writeOutput("#URL.sourceFile# minified and written to #URL.destinationFile#"); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment