Skip to content

Instantly share code, notes, and snippets.

@anilsakr
Created April 25, 2020 11:28
Show Gist options
  • Save anilsakr/425954517bb49ad5ff070f7974639877 to your computer and use it in GitHub Desktop.
Save anilsakr/425954517bb49ad5ff070f7974639877 to your computer and use it in GitHub Desktop.
location /sumdemo {
set $diff ''; # we have to predefine the $diff variable here
set_by_lua $sum '
local a = 32
local b = 56
ngx.var.diff = a - b; -- write to $diff directly
return a + b; -- return the $sum value normally
';
echo "sum = $sum, diff = $diff";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment