bdw429s
08/12/2022, 3:06 PMdanmurphy
08/12/2022, 3:08 PMdanmurphy
08/12/2022, 3:14 PMcomponent extends=coldbox.system.RestHandler {
property name='myService' inject='id';
safetyCatches( event, rc, prc) {
var issues = myService.list( params );
}
improvements( event, rc, prc) {
var issues = myService.list( params );
}
}
danmurphy
08/12/2022, 3:15 PMcomponent extends=coldbox.system.RestHandler {
safetyCatches( event, rc, prc) {
var issues = getInstance( 'myService' ).list( params );
}
improvements( event, rc, prc) {
var issues = getInstance( 'myService' ).list( params );
}
}
bdw429s
08/12/2022, 3:33 PMbdw429s
08/12/2022, 3:33 PMmyService
bdw429s
08/12/2022, 3:34 PMdanmurphy
08/12/2022, 4:14 PMbdw429s
08/12/2022, 4:16 PMmyService
or downstream of thatdanmurphy
08/12/2022, 4:16 PMmyService
is being injected as a singleton because handlerCaching is on, which makes the handler a Singleton. Gotcha, good to know.bdw429s
08/12/2022, 4:16 PMdanmurphy
08/12/2022, 4:19 PMcomponent {
property name='jira' inject='coldbox:setting:jira';
function init() {
return this;
}
function list( required jql, maxResults = 50 ) {
cfhttp(
method = 'GET',
url = 'https://' & jira.hostname & '/rest/api/2/search?jql=' & arguments.jql & '&maxResults=' & arguments.maxResults,
charset = 'utf-8',
username = jira.username,
password = jira.password,
result = 'result'
) {
cfhttpparam(
type = 'header',
name = 'Content-Type',
value = 'application/json'
);
}
if ( result.statuscode EQ 200 ) {
var content = deserializeJSON( result.filecontent );
result.append( { 'total' : content.total } );
result.append( { 'issues' : content.issues } );
return result;
} else {
return result;
}
}
}
bdw429s
08/12/2022, 4:19 PMresult
isn't varreddanmurphy
08/12/2022, 4:19 PMdanmurphy
08/12/2022, 4:19 PMdanmurphy
08/12/2022, 4:20 PMdanmurphy
08/12/2022, 4:20 PMdanmurphy
08/12/2022, 4:21 PMbdw429s
08/12/2022, 4:22 PMdanmurphy
08/12/2022, 4:22 PMbdw429s
08/12/2022, 4:23 PMbdw429s
08/12/2022, 4:23 PMresult = 'local.result'
bdw429s
08/12/2022, 4:23 PMvar result='';
cfttp...
but I prefer to keep it together and not separate the declarationdanmurphy
08/12/2022, 4:24 PMdanmurphy
08/12/2022, 4:24 PMdanmurphy
08/12/2022, 4:25 PMdanmurphy
08/12/2022, 4:26 PMbdw429s
08/12/2022, 4:26 PMdanmurphy
08/12/2022, 4:26 PMbdw429s
08/12/2022, 4:26 PMdanmurphy
08/12/2022, 4:27 PMbdw429s
08/12/2022, 4:31 PMbdw429s
08/12/2022, 4:32 PMbdw429s
08/12/2022, 4:33 PMbdw429s
08/12/2022, 4:33 PMbdw429s
08/12/2022, 4:34 PMDave Merrill
08/12/2022, 5:30 PMDave Merrill
08/12/2022, 5:30 PMdanmurphy
08/12/2022, 5:37 PMlocal.result
makes it all work as expected. Man, good lesson learned. Now to go search for other uses of cfhttp, cfexecute, cfldap, etc. where they just have a return variable and we’re probably not scoping it…danmurphy
08/12/2022, 5:38 PMbdw429s
08/12/2022, 6:07 PMbdw429s
08/12/2022, 6:08 PMvariable
scope from the CFCdanmurphy
08/12/2022, 6:12 PMbdw429s
08/12/2022, 7:57 PMbdw429s
08/12/2022, 7:57 PMdanmurphy
08/12/2022, 7:58 PMbdw429s
08/12/2022, 7:59 PMdanmurphy
08/12/2022, 8:21 PMbdw429s
08/12/2022, 8:22 PMdanmurphy
08/12/2022, 8:23 PM/leakDetector
url (which sounds like something I could’ve used when we still had babies in diapers).bdw429s
08/12/2022, 8:23 PMbdw429s
08/12/2022, 8:24 PMbdw429s
08/12/2022, 8:24 PMbdw429s
08/12/2022, 8:25 PMdanmurphy
08/12/2022, 8:45 PMdanmurphy
08/12/2022, 8:45 PMbdw429s
08/12/2022, 8:46 PMbdw429s
08/12/2022, 8:46 PMbdw429s
08/12/2022, 8:46 PMbdw429s
08/12/2022, 8:47 PMbdw429s
08/12/2022, 8:47 PMvariables.cfstoredProc
which get created EVEN IF you are using the results
attribute.bdw429s
08/12/2022, 8:50 PMbdw429s
08/12/2022, 8:51 PMbdw429s
08/12/2022, 8:51 PMdanmurphy
08/12/2022, 8:52 PMbdw429s
08/12/2022, 8:52 PMEXECUTIONTIME
was another one I already ignore. There was some tag in CF that always created that variable regardlesbdw429s
08/12/2022, 8:52 PMdanmurphy
08/12/2022, 8:54 PMbdw429s
08/12/2022, 8:54 PMdanmurphy
08/12/2022, 8:55 PMbdw429s
08/12/2022, 8:56 PMcfquery
danmurphy
08/12/2022, 8:56 PMbdw429s
08/12/2022, 8:57 PMdanmurphy
08/12/2022, 8:57 PMbdw429s
08/12/2022, 8:58 PMbdw429s
08/12/2022, 8:59 PMbdw429s
08/12/2022, 8:59 PMbdw429s
08/12/2022, 9:00 PMbdw429s
08/12/2022, 9:00 PMbdw429s
08/12/2022, 9:01 PMbdw429s
08/12/2022, 9:02 PMorder.cfc
stored in someone's shopping cart with their items, or a user.cfc
in session to track the logged in user or a product.cfc
instance returned from the DB to represent something being displayed on that page would all be transients. You create them when you need and they are only visilble to one request or user's sesion, etcdanmurphy
08/12/2022, 9:02 PMbdw429s
08/12/2022, 9:03 PMsession
is also a scope you can ask WireBox to store a CFC in automaticallybdw429s
08/12/2022, 9:03 PMbdw429s
08/12/2022, 9:03 PMbdw429s
08/12/2022, 9:04 PMdanmurphy
08/12/2022, 9:04 PMbdw429s
08/12/2022, 9:05 PMcomponent scope="session" {
}
Then you can just do
currentUser = getinstance( 'user' )
and wirebox will give you the current user for that session, creating it if necessarybdw429s
08/12/2022, 9:05 PMapplication
scope (technically the "singleton" scope is bound to the wirebox injector)danmurphy
08/12/2022, 9:06 PMbdw429s
08/12/2022, 9:06 PMbdw429s
08/12/2022, 9:06 PMdanmurphy
08/12/2022, 9:06 PMbdw429s
08/12/2022, 9:50 PMoldValue.toString() != scopeValue.toString()
the best thing to do would be to add
property name="allowedFilters";
to the CFC and the leak detector will start ignoring itbdw429s
08/12/2022, 9:52 PMdanmurphy
08/12/2022, 9:53 PM