Forum Discussion

mikey_webb's avatar
May 30, 2019

iRule to intercept request and respond to client with content

Please help

 

Require an iRule to intercept a specific URI pattern and when the pattern is received instead of going to the pool return

an HTTP response code 200 back with the following content {"result":null,"errors":[],"warnings":[],"hasErrors":false,"hasWarnings":false}

 

Many thanks for any guidance

2 Replies

  • Try this

    when HTTP_REQUEST {
        set message "{\"result\":null,\"errors\":[],\"warnings\":[],\"hasErrors\":false,\"hasWarnings\":false}"
        if {[HTTP::uri] equals "/my/path"} {
            HTTP::respond 200 -version 1.1 content $message noserver "Content-Type" "application/json" "Connection" "close"
        }
    }