• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Configuration variables for a REST cfc

Explorer ,
Nov 03, 2014 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

247

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
community guidelines
LEGEND ,
Nov 03, 2014 Nov 03, 2014

Copy link to clipboard

Copied

LATEST

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,

^_^

Votes

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
community guidelines
Resources
Documentation