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: doc/HttpLuaModule.wiki
+21-21Lines changed: 21 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1123,14 +1123,14 @@ You can also initialize the [[#lua_shared_dict|lua_shared_dict]] shm storage at
1123
1123
lua_shared_dict dogs 1m;
1124
1124
1125
1125
init_by_lua_block {
1126
-
local dogs = ngx.shared.dogs;
1126
+
local dogs = ngx.shared.dogs
1127
1127
dogs:set("Tom", 56)
1128
1128
}
1129
1129
1130
1130
server {
1131
1131
location = /api {
1132
1132
content_by_lua_block {
1133
-
local dogs = ngx.shared.dogs;
1133
+
local dogs = ngx.shared.dogs
1134
1134
ngx.say(dogs:get("Tom"))
1135
1135
}
1136
1136
}
@@ -1351,8 +1351,8 @@ a time. However, a workaround is possible using the [[#ngx.var.VARIABLE|ngx.var.
1351
1351
local a = 32
1352
1352
local b = 56
1353
1353
1354
-
ngx.var.diff = a - b; -- write to $diff directly
1355
-
return a + b; -- return the $sum value normally
1354
+
ngx.var.diff = a - b -- write to $diff directly
1355
+
return a + b -- return the $sum value normally
1356
1356
';
1357
1357
1358
1358
echo "sum = $sum, diff = $diff";
@@ -1541,7 +1541,7 @@ The right way of doing this is as follows:
1541
1541
rewrite_by_lua '
1542
1542
ngx.var.b = tonumber(ngx.var.a) + 1
1543
1543
if tonumber(ngx.var.b) == 13 then
1544
-
return ngx.redirect("/bar");
1544
+
return ngx.redirect("/bar")
1545
1545
end
1546
1546
';
1547
1547
@@ -2824,7 +2824,7 @@ For example:
2824
2824
location /foo {
2825
2825
set $my_var ''; # this line is required to create $my_var at config time
2826
2826
content_by_lua_block {
2827
-
ngx.var.my_var = 123;
2827
+
ngx.var.my_var = 123
2828
2828
...
2829
2829
}
2830
2830
}
@@ -3247,7 +3247,7 @@ This option is set to <code>false</code> by default
3247
3247
set $dog 'hello';
3248
3248
content_by_lua_block {
3249
3249
res = ngx.location.capture("/other",
3250
-
{ share_all_vars = true });
3250
+
{ share_all_vars = true })
3251
3251
3252
3252
ngx.print(res.body)
3253
3253
ngx.say(ngx.var.uri, ": ", ngx.var.dog)
@@ -3311,7 +3311,7 @@ unescaping them in the Nginx config file.
3311
3311
set $cat '';
3312
3312
content_by_lua_block {
3313
3313
res = ngx.location.capture("/other",
3314
-
{ vars = { dog = "hello", cat = 32 }});
3314
+
{ vars = { dog = "hello", cat = 32 }})
3315
3315
3316
3316
ngx.print(res.body)
3317
3317
}
@@ -3338,8 +3338,8 @@ The <code>ctx</code> option can be used to specify a custom Lua table to serve a
3338
3338
local ctx = {}
3339
3339
res = ngx.location.capture("/sub", { ctx = ctx })
3340
3340
3341
-
ngx.say(ctx.foo);
3342
-
ngx.say(ngx.ctx.foo);
3341
+
ngx.say(ctx.foo)
3342
+
ngx.say(ngx.ctx.foo)
3343
3343
}
3344
3344
}
3345
3345
</geshi>
@@ -3356,13 +3356,13 @@ It is also possible to use this <code>ctx</code> option to share the same [[#ngx
3356
3356
<geshi lang="nginx">
3357
3357
location /sub {
3358
3358
content_by_lua_block {
3359
-
ngx.ctx.foo = "bar";
3359
+
ngx.ctx.foo = "bar"
3360
3360
}
3361
3361
}
3362
3362
location /lua {
3363
3363
content_by_lua_block {
3364
3364
res = ngx.location.capture("/sub", { ctx = ngx.ctx })
3365
-
ngx.say(ngx.ctx.foo);
3365
+
ngx.say(ngx.ctx.foo)
3366
3366
}
3367
3367
}
3368
3368
</geshi>
@@ -3486,9 +3486,9 @@ The header names are matched case-insensitively.
3486
3486
3487
3487
<geshi lang="lua">
3488
3488
-- equivalent to ngx.header["Content-Type"] = 'text/plain'
3489
-
ngx.header.content_type = 'text/plain';
3489
+
ngx.header.content_type = 'text/plain'
3490
3490
3491
-
ngx.header["X-My-Header"] = 'blah blah';
3491
+
ngx.header["X-My-Header"] = 'blah blah'
3492
3492
</geshi>
3493
3493
3494
3494
Multi-value headers can be set this way:
@@ -3521,13 +3521,13 @@ is equivalent to
3521
3521
Setting a slot to <code>nil</code> effectively removes it from the response headers:
3522
3522
3523
3523
<geshi lang="lua">
3524
-
ngx.header["X-My-Header"] = nil;
3524
+
ngx.header["X-My-Header"] = nil
3525
3525
</geshi>
3526
3526
3527
3527
The same applies to assigning an empty table:
3528
3528
3529
3529
<geshi lang="lua">
3530
-
ngx.header["X-My-Header"] = {};
3530
+
ngx.header["X-My-Header"] = {}
3531
3531
</geshi>
3532
3532
3533
3533
Setting <code>ngx.header.HEADER</code> after sending out response headers (either explicitly with [[#ngx.send_headers|ngx.send_headers]] or implicitly with [[#ngx.print|ngx.print]] and similar) will log an error message.
@@ -4403,8 +4403,8 @@ Does an internal redirect to <code>uri</code> with <code>args</code> and is simi
4403
4403
4404
4404
<geshi lang="lua">
4405
4405
ngx.exec('/some-location');
4406
-
ngx.exec('/some-location', 'a=3&b=5&c=6');
4407
-
ngx.exec('/some-location?a=3&b=5', 'c=6');
4406
+
ngx.exec('/some-location', 'a=3&b=5&c=6')
4407
+
ngx.exec('/some-location?a=3&b=5', 'c=6')
4408
4408
</geshi>
4409
4409
4410
4410
The optional second <code>args</code> can be used to specify extra URI query arguments, for example:
@@ -4430,7 +4430,7 @@ Named locations are also supported but the second <code>args</code> argument wil
4430
4430
<geshi lang="nginx">
4431
4431
location /foo {
4432
4432
content_by_lua_block {
4433
-
ngx.exec("@bar", "a=goodbye");
4433
+
ngx.exec("@bar", "a=goodbye")
4434
4434
}
4435
4435
}
4436
4436
@@ -4509,7 +4509,7 @@ This method is similar to the [[HttpRewriteModule#rewrite|rewrite]] directive wi
4509
4509
is equivalent to the following Lua code
4510
4510
4511
4511
<geshi lang="lua">
4512
-
return ngx.redirect('/foo'); -- Lua code
4512
+
return ngx.redirect('/foo') -- Lua code
4513
4513
</geshi>
4514
4514
4515
4515
while
@@ -7377,7 +7377,7 @@ For example, the following [[HttpSetMiscModule]] directives can be invoked this
0 commit comments