-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-validation.lua
More file actions
25 lines (20 loc) · 991 Bytes
/
example-validation.lua
File metadata and controls
25 lines (20 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
- inside the lua script users has access to three global variables:
- status_code: http status code returned in the http request
- headers: a table containing all the headers in the response
- body: response body
this allows the users to customize what a healthy response from the service looks like:
NOTE: the script must return true/false
NOTE: the script is stored in the GSLB - config
*/
-- Check status code only
return status_code >= 200 and status_code < 400
-- Check status and body content
return status_code == 200 and string.find(body, "healthy") ~= nil
-- Check status and header
return status_code == 200 and headers["Content-Type"] == "application/json"
-- Complex check with multiple conditions
local status_ok = status_code >= 200 and status_code < 300
local has_json = headers["Content-Type"] == "application/json"
local valid_body = string.find(body, '"status":"ok"') ~= nil
return status_ok and has_json and valid_body