test.cfm

<cfscript> // Construct the root URL that we are going to hit (sibling to this template). host = "http://#cgi.server_name#:#cgi.server_port#"; wwwRoot = getDirectoryFromPath( cgi.script_name ); targetUrl = ( host & wwwRoot & "target.cfm" ); // The "target.cfm" end-point does nothing but serialize and return the incoming HTTP // HEADERS as a JSON (JavaScript Object Notation) payload. Our goal here is to see if // we can compose that set of HTTP headers across a series of Function calls. http result = "targetResponse" method = "get" url = targetUrl { // Gather "httpParam" TAGS across external function calls. injectAuthorizationHeaders(); injectTracingHeaders(); // Mix-in our own "local" header. httpParam type = "header" name = "X-Meep" value = "moop" ; } // Output the HTTP HEADERS that the target end-point found and returned. dump( deserializeJson( targetResponse.fileContent ) ); // ------------------------------------------------------------------------------- // // ------------------------------------------------------------------------------- // /** * I apply the Authorization HTTP header to the current HTTP context. */ public void function injectAuthorizationHeaders() { httpParam type = "header" name = "Authorization" value = "Bearer: ICANHASCHEEZEBURGER" ; } /** * I apply the tracing HTTP headers to the current HTTP context. */ public void function injectTracingHeaders() { param name = "request.requestID" type = "string" default = "request-#createUuid()#" ; httpParam type = "header" name = "X-Request-ID" value = request.requestID ; } </cfscript>
Spreading Http And HttpParam Tags Across Multiple Function Calls In Lucee CFML 5.3.8.201

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.