forked from api7/lua-resty-healthcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support setting function modules for xrpc (#2)
- Loading branch information
Showing
3 changed files
with
179 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local http = require('resty.http') | ||
local json = require('cjson') | ||
|
||
return function (node, conf) | ||
ngx.log(ngx.INFO, "http_handler node: ", json.encode(node), " conf: ", json.encode(conf)) | ||
conf = conf or {} | ||
local httpc = http.new() | ||
local uri = "http://" .. node.host .. ":" .. node.port | ||
local res, err = httpc:request_uri(uri, { | ||
method = conf.method or "GET", | ||
path = conf.path or "/status", | ||
}) | ||
if not res then | ||
ngx.log(ngx.ERR, "failed to request: ", err) | ||
return false | ||
end | ||
return true, res.status | ||
end |