openresty / lua-resty-upstream-healthcheck

Health Checker for Nginx Upstream Servers in Pure Lua
521 stars 134 forks source link

add status_page_one function #22

Closed xerox-xeon closed 4 years ago

xerox-xeon commented 8 years ago

Hello, my name is Shao Dong, I recently in the work with your products, in order to work need me add a function(status_page_one), you see, is not useful, can be merge

agentzh commented 8 years ago

@lifeblood Could you describe the purpose and usage of your new addition? Why should we have it? And how are we going to use it?

xerox-xeon commented 8 years ago

generate an HTML page for specified upstream with URL Parameter for example: http://domain.com/status_one?upstream=foo generate foo upstream status page

        location /status_one {
            access_log off;
            default_type text/plain;
            content_by_lua_block {
                    local hc = require "resty.upstream.healthcheck"
                    ngx.say("Nginx Worker PID: ", ngx.worker.pid())
                    ngx.print(hc.status_page_one())
            }
        }
xerox-xeon commented 8 years ago

get_upstreams() can be obtain one upstream?

agentzh commented 8 years ago

@lifeblood You can use the Lua if statement to branch the code, no?

xerox-xeon commented 8 years ago

Ok

xerox-xeon commented 8 years ago

have done, pls check.

xerox-xeon commented 8 years ago

Is there any place to improve?