Skip to content

Instantly share code, notes, and snippets.

@jobjects
Created July 21, 2018 14:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jobjects/2c453e345ba366efd672f2ed471c6e5a to your computer and use it in GitHub Desktop.
Intercept highlighting request and update parameters
/*
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