Forum Discussion
Chris_123510
Nimbostratus
Nov 20, 2013Using iRules for JSON response
I am looking for examples of how to set up the LTM to respond to JSON requests using an iRule. When we send back the HTML response page it is locking up our vendors system, so we would like to change...
Sam_Richman_263
Nov 27, 2013Historic F5 Account
From my understanding, the requirement here is to present JSON content back to the requestor in the event that the JSON request triggers an ASM blocking page. What about something like the following:
when HTTP_REQUEST {
if { [HTTP::header "Content-Type"] contains "json" } {
set json_content 1
} else {
set json_content 0
}
}
when ASM_REQUEST_BLOCKING
{
if { $json_content }
{
HTTP::header remove Content-Length
HTTP::header insert header_1 value_1
set response "{ \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", \"GlossList\": { \"GlossEntry\": { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", \"GlossDef\": { \"para\": \"Request has been blocked.\", \"GlossSeeAlso\": \[\"GML\", \"XML\"\] }, \"GlossSee\": \"markup\" } } } } }"
ASM::payload replace 0 [ASM::payload length] ""
ASM::payload replace 0 0 $response
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
