1 Reply Latest reply on Nov 3, 2014 8:37 AM by WolfShade

    Configuration variables for a REST cfc

    ccsimmons

      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?

        • 1. Re: Configuration variables for a REST cfc
          WolfShade Level 4

          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,

           

          ^_^