Created
July 21, 2018 14:43
Star
You must be signed in to star a gist
Intercept highlighting request and update parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
To use, add to Highlighter's application.conf: | |
highlighter.service.scripting { | |
files = ["/path/to/highlighter-snoop-script.groovy"] | |
filterRequestParamsFn = "myRequestParamsFilter" | |
uriFilterFn = "myUriFilterFn" | |
} | |
If all setup fine, you should see below logged messages in highlighter.log | |
*/ | |
import javax.servlet.http.HttpServletRequest | |
def init() { | |
log.info("My script is loaded: {}", scriptPath) | |
} | |
def myRequestParamsFilter(Map params, HttpServletRequest req) { | |
log.info("My request filter:") | |
log.info(" params: {}", params) | |
log.info(" request: {}", req) | |
// update params map here if you need... | |
} | |
def myUriFilterFn(String uri) { | |
String newUri = uri | |
// here we could do something here to transform received uri to a local file path for example | |
// ... | |
return newUri | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment