Highlighted

Configuration variables for a REST cfc

Explorer ,
Nov 03, 2014

Copy link to clipboard

Copied

I am creating my first RESTful cfc which will allow a legacy system to interact with a more current system.  There are some "configuration" variables that need to be available to a couple of functions in the cfc.  These variables are mainly for disk paths and an API key.  What is the best practice for setting these variables in my RESTful cfc?  Should I just declare them at the beginning of the component outside the functions in the variables scope?  Do I need an init function?  If I use an init function how does it get called when the other functions are only called via REST?

Views

190

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Configuration variables for a REST cfc

Explorer ,
Nov 03, 2014

Copy link to clipboard

Copied

I am creating my first RESTful cfc which will allow a legacy system to interact with a more current system.  There are some "configuration" variables that need to be available to a couple of functions in the cfc.  These variables are mainly for disk paths and an API key.  What is the best practice for setting these variables in my RESTful cfc?  Should I just declare them at the beginning of the component outside the functions in the variables scope?  Do I need an init function?  If I use an init function how does it get called when the other functions are only called via REST?

Views

191

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 03, 2014 0
LEGEND ,
Nov 03, 2014

Copy link to clipboard

Copied

I think you can declare them in the beginning of the component prior to any functions.  You can include an init function, and just call it the same as you would call any other function.

<cffunction name="init">

<cfreturn this />

</cffunction>

<cfset tmp = path.to.component.init()>

I haven't worked with that, myself, but I've seen lots of code do that.

HTH,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2014 0