Forum Discussion
RossVermette
Nimbostratus
Feb 17, 2016AppDynamics custom script injection
Hey,
I'm looking for a way to host a java script file name adrum.js (either by using an iFile or other method) and modify a variable that is set in that file based on HTTP host header name match...
Kai_Wilke
MVP
Feb 18, 2016Hi Ross,
check the iRule below to see how your *.js can be fetched from an iFile with the additional "adrum-app-key" content replacement...
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] eq "/adrum.js" } then {
HTTP::respond 200 content [string map [list "adrum-app-key" [class lookup [HTTP::host] DATAGROUP1]] [ifile get "ifile-adrum.js"]] content-type "text/javascript"
}
}
... to understand this code you may also read the very much less optimized version of...
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] eq "/adrum.js" } then {
set APP_VAR_NAME [class lookup [HTTP::host] DATAGROUP1]
set APP_VAR_NAME_REPLACEMENT [list "adrum-app-key" $APP_VAR_NAME]
set IFILE_RAW_CONTENT [ifile get "ifile-adrum.js"]
set IFILE_FINAL_CONTENT [string map $APP_VAR_NAME_REPLACEMENT $IFILE_RAW_CONTENT]
HTTP::respond 200 content $IFILE_FINAL_CONTENT Content-Type "text/javascript"
}
}
Cheers, Kai
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects