basic API to be used in swarm mode

This commit is contained in:
bunkerity
2021-03-12 10:42:31 +01:00
parent 781e4c8cbb
commit 7509ec2f2c
5 changed files with 64 additions and 0 deletions

20
confs/global/api.conf Normal file
View File

@@ -0,0 +1,20 @@
rewrite_by_lua_block {
local api = require "api"
if api.is_api_call() then
ngx.header.content_type = 'text/plain'
if api.do_api_call() then
ngx.log(ngx.WARN, "[API] API call " .. ngx.var.request_uri .. " successfull from " .. ngx.var.remote_addr)
ngx.say("ok")
else
ngx.log(ngx.WARN, "[API] API call " .. ngx.var.request_uri .. " failed from " .. ngx.var.remote_addr)
ngx.say("ko")
end
ngx.exit(ngx.HTTP_OK)
end
ngx.exit(ngx.OK)
}

View File

@@ -111,4 +111,7 @@ http {
# server config(s)
%INCLUDE_SERVER%
# API
%USE_API%
}