json & jpg in irule

Hi,

target : make a maintenance page by the F5.

I have a maintenance page on json language. I try to make an irule in differents ways but it doesn’t work :

- by stream::expression

- by ifile (get ifile with the .json)

Here is a peace of my irule :

when HTTP_REQUEST {

if { [active_members [LB::server pool]] < 1 } {

HTTP::respond 503 content

STREAM::expression{@@“json_script_here”}

STREAM::enable

}

}

Or :

when HTTP_REQUEST {

if { [active_members [LB::server pool]] < 1 } {

HTTP::respond 503 content

ifile get my_json_file.json “Content-Type” “application/json” “Cache-Control” “no-cache”

}

}

can you try this?

when HTTP_REQUEST {
  if { [active_members [LB::server pool]] < 1 } {
    HTTP::respond 503 content [ifile get my_json_file.json] "Content-Type" "application/json" "Cache-Control" "no-cache"
  }
}

Yes,

the browser displays the json code :frowning:

I’m assuming the JSON data is some content *within* an HTML file, or called from an HTML file? If so, do you need to replace the HTML content completely, or just the referenced JSON? The 503 response you’re trying to respond with needs to be HTML content for the browser to render.

It’s a .json file.

I will try to do this with an html file including the json script

You can still call the JSON file separately, as an object referenced by the HTML, but the browser needs something that it can render.

Posted By nitass on 06/24/2013 06:16 AM

can you try this?

when HTTP_REQUEST { if { [active_members [LB::server pool]] < 1 } { HTTP::respond 503 content [ifile get my_json_file.json] "Content-Type" "application/json" "Cache-Control" "no-cache" } }

Hi,

It seems that the right way. The code is display by a specific application.

Thanks for support :slightly_smiling_face: