--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
routes = [
// root/default
{
pattern="/",
handler="readmeHandler",
action="index"
},
// geocode new address
{
pattern="/address",
handler="geocoderHandler",
action={
POST="new"
}
},
// get geocode totals
{
pattern="/geocode/totals",
handler="geocoderHandler",
action={
GET="totals"
}
},
// Convention Route
{
pattern="/:handler/:action?"}
];
function new(event,rc,prc){
prc.results.data = paagGeocoder.geocodeSingleAddress(rc);
}
component {
public void function preHandler(event,rc,prc){
prc.results = {};
prc.results["status"] = "OK";
prc.results["data"] = {};
prc.results["message"] = "";
event.paramValue("format","json");
}
public void function postHandler(event,rc,prc){
renderResults(event,prc.results);
}
// Any process level error that inheriting handlers do not catch will be caught
// by this onError.
public any function onError(event,faultAction,exception,eventArguments){
prc.results.status = "FAIL";
prc.results.message = ARGUMENTS.exception.message;
prc.results.data = ARGUMENTS.exception.tagContext;
// TODO: log error here
// Use LogBox Appenders, ie: db, trace, email
// pass the results
renderResults(ARGUMENTS.event, prc.results);
}
private any function renderResults(event,results){
// return if PROXY
if( ARGUMENTS.event.isProxyRequest() ){
return ARGUMENTS["results"];
}
// NOTE: Config/Routes.cfm has extensions settings turned on
// if a detected extension is not part of the allowed extensions
// then coldbox will thrown an invalid event error, this is when
// onError kicks in.
switch( event.getValue('format') ) {
case "jsonp":
if(event.valueExists( name="callback", private=false )){
event.renderData( data=ARGUMENTS["results"], type="jsonp", jsoncallback=event.getValue('callback') );
}else{
var errorStruct = {status="FAIL", message="MISSING_CALLBACK"};
event.renderData( data=errorStruct, type="jsonp", jsoncallback="fail" );
}
break;
default:
event.renderData( data=ARGUMENTS["results"], type=event.getValue('format') );
break;
}
}
}
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--------- Original Message ---------
--
this.geocodeSingleAddress = function(address){
// returns google api response includes coordinates
// return $http.post(apiUrlBase + '/address',address);
return $http.get(apiUrlBase + '/address?address='+address.address+'&city='+address.city+'&state='+address.state+'&zip='+address.zip);
};
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
try {
// deserialize application/json type requests
if( getHTTPRequestData().headers["Content-Type"] eq "application/json" ){
requestBody = toString( getHttpRequestData().content );
if ( len( requestBody ) ) {
structAppend( form, deserializeJson( requestBody ) );
}
}
}
catch(any error) {}
this.geocodeSingleAddress = function(address){
// returns google api response includes coordinates
// return $http.post(apiUrlBase + '/address',address);
return $http({ method: "POST", url: apiUrlBase + '/address', data: $.param(address), headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); };