You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+21-21Lines changed: 21 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1402,14 +1402,14 @@ You can also initialize the [lua_shared_dict](#lua_shared_dict) shm storage at t
1402
1402
lua_shared_dict dogs 1m;
1403
1403
1404
1404
init_by_lua_block {
1405
-
local dogs = ngx.shared.dogs;
1405
+
local dogs = ngx.shared.dogs
1406
1406
dogs:set("Tom", 56)
1407
1407
}
1408
1408
1409
1409
server {
1410
1410
location = /api {
1411
1411
content_by_lua_block {
1412
-
local dogs = ngx.shared.dogs;
1412
+
local dogs = ngx.shared.dogs
1413
1413
ngx.say(dogs:get("Tom"))
1414
1414
}
1415
1415
}
@@ -1659,8 +1659,8 @@ a time. However, a workaround is possible using the [ngx.var.VARIABLE](#ngxvarva
1659
1659
local a = 32
1660
1660
local b = 56
1661
1661
1662
-
ngx.var.diff = a - b; -- write to $diff directly
1663
-
return a + b; -- return the $sum value normally
1662
+
ngx.var.diff = a - b -- write to $diff directly
1663
+
return a + b -- return the $sum value normally
1664
1664
';
1665
1665
1666
1666
echo "sum = $sum, diff = $diff";
@@ -1874,7 +1874,7 @@ The right way of doing this is as follows:
1874
1874
rewrite_by_lua '
1875
1875
ngx.var.b = tonumber(ngx.var.a) + 1
1876
1876
if tonumber(ngx.var.b) == 13 then
1877
-
return ngx.redirect("/bar");
1877
+
return ngx.redirect("/bar")
1878
1878
end
1879
1879
';
1880
1880
@@ -3480,7 +3480,7 @@ For example:
3480
3480
location /foo {
3481
3481
set $my_var ''; # this line is required to create $my_var at config time
3482
3482
content_by_lua_block {
3483
-
ngx.var.my_var = 123;
3483
+
ngx.var.my_var = 123
3484
3484
...
3485
3485
}
3486
3486
}
@@ -3948,7 +3948,7 @@ This option is set to `false` by default
3948
3948
set $dog 'hello';
3949
3949
content_by_lua_block {
3950
3950
res = ngx.location.capture("/other",
3951
-
{ share_all_vars = true });
3951
+
{ share_all_vars = true })
3952
3952
3953
3953
ngx.print(res.body)
3954
3954
ngx.say(ngx.var.uri, ": ", ngx.var.dog)
@@ -3976,7 +3976,7 @@ The `copy_all_vars` option provides a copy of the parent request's Nginx variabl
3976
3976
set $dog 'hello';
3977
3977
content_by_lua_block {
3978
3978
res = ngx.location.capture("/other",
3979
-
{ copy_all_vars = true });
3979
+
{ copy_all_vars = true })
3980
3980
3981
3981
ngx.print(res.body)
3982
3982
ngx.say(ngx.var.uri, ": ", ngx.var.dog)
@@ -4014,7 +4014,7 @@ unescaping them in the Nginx config file.
4014
4014
set $cat '';
4015
4015
content_by_lua_block {
4016
4016
res = ngx.location.capture("/other",
4017
-
{ vars = { dog = "hello", cat = 32 }});
4017
+
{ vars = { dog = "hello", cat = 32 }})
4018
4018
4019
4019
ngx.print(res.body)
4020
4020
}
@@ -4042,8 +4042,8 @@ The `ctx` option can be used to specify a custom Lua table to serve as the [ngx.
4042
4042
local ctx = {}
4043
4043
res = ngx.location.capture("/sub", { ctx = ctx })
4044
4044
4045
-
ngx.say(ctx.foo);
4046
-
ngx.say(ngx.ctx.foo);
4045
+
ngx.say(ctx.foo)
4046
+
ngx.say(ngx.ctx.foo)
4047
4047
}
4048
4048
}
4049
4049
```
@@ -4061,13 +4061,13 @@ It is also possible to use this `ctx` option to share the same [ngx.ctx](#ngxctx
4061
4061
4062
4062
location /sub {
4063
4063
content_by_lua_block {
4064
-
ngx.ctx.foo = "bar";
4064
+
ngx.ctx.foo = "bar"
4065
4065
}
4066
4066
}
4067
4067
location /lua {
4068
4068
content_by_lua_block {
4069
4069
res = ngx.location.capture("/sub", { ctx = ngx.ctx })
4070
-
ngx.say(ngx.ctx.foo);
4070
+
ngx.say(ngx.ctx.foo)
4071
4071
}
4072
4072
}
4073
4073
```
@@ -4245,14 +4245,14 @@ Setting a slot to `nil` effectively removes it from the response headers:
4245
4245
4246
4246
```lua
4247
4247
4248
-
ngx.header["X-My-Header"] =nil;
4248
+
ngx.header["X-My-Header"] =nil
4249
4249
```
4250
4250
4251
4251
The same applies to assigning an empty table:
4252
4252
4253
4253
```lua
4254
4254
4255
-
ngx.header["X-My-Header"] = {};
4255
+
ngx.header["X-My-Header"] = {}
4256
4256
```
4257
4257
4258
4258
Setting `ngx.header.HEADER` after sending out response headers (either explicitly with [ngx.send_headers](#ngxsend_headers) or implicitly with [ngx.print](#ngxprint) and similar) will log an error message.
@@ -5254,9 +5254,9 @@ Does an internal redirect to `uri` with `args` and is similar to the [echo_exec]
5254
5254
5255
5255
```lua
5256
5256
5257
-
ngx.exec('/some-location');
5258
-
ngx.exec('/some-location', 'a=3&b=5&c=6');
5259
-
ngx.exec('/some-location?a=3&b=5', 'c=6');
5257
+
ngx.exec('/some-location')
5258
+
ngx.exec('/some-location', 'a=3&b=5&c=6')
5259
+
ngx.exec('/some-location?a=3&b=5', 'c=6')
5260
5260
```
5261
5261
5262
5262
The optional second `args` can be used to specify extra URI query arguments, for example:
@@ -5285,7 +5285,7 @@ Named locations are also supported but the second `args` argument will be ignore
5285
5285
5286
5286
location /foo {
5287
5287
content_by_lua_block {
5288
-
ngx.exec("@bar", "a=goodbye");
5288
+
ngx.exec("@bar", "a=goodbye")
5289
5289
}
5290
5290
}
5291
5291
@@ -5373,7 +5373,7 @@ is equivalent to the following Lua code
0 commit comments