openresty / echo-nginx-module

An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file
http://wiki.nginx.org/NginxHttpEchoModule
BSD 2-Clause "Simplified" License
1.17k stars 254 forks source link

Add null option to ignore content output of sub-requests #17

Open Downchuck opened 11 years ago

Downchuck commented 11 years ago

If it's feasible, an option for echo_location and echo_location_async to ignore the output of the subrequests would be helpful for running some subrequests that handle various cleanup. memcache "get" followed by memc "delete" for example.

agentzh commented 11 years ago

Hello!

On Sun, Apr 14, 2013 at 6:33 PM, Charles Pritchard <notifications@github.com

wrote:

If it's feasible, an option for echo_location and echo_location_async to ignore the output of the subrequests would be helpful for running some subrequests that handle various cleanup. memc "get" followed by memc "delete" for example.

This can be trivially achieved via the ngx_lua module, for instance,

location = /t {
    access_by_lua '
        ngx.location.capture("/memc?key=foo&cmd=get")
        ngx.location.capture("/memc?key=foo&cmd=delete")
    ';
    echo hello world;
}

See http://wiki.nginx.org/HttpLuaModule for details.

I'd make ngx_echo stay simple :)

Best regards, -agentzh