Willy Tarreau | d4359fd | 2021-04-02 10:49:34 +0200 | [diff] [blame] | 1 | -- http-response actions |
| 2 | core.register_action("set-status-418-defaultreason", {"http-res"}, function(txn) |
| 3 | txn.http:res_set_status(418) |
| 4 | end) |
| 5 | core.register_action("set-status-418-customreason", {"http-res"}, function(txn) |
| 6 | txn.http:res_set_status(418, "I'm a coffeepot") |
| 7 | end) |
| 8 | |
| 9 | -- http services |
| 10 | core.register_service("http418-default", "http", function(applet) |
| 11 | local response = "Hello World !" |
| 12 | applet:set_status(418) |
| 13 | applet:add_header("content-length", string.len(response)) |
| 14 | applet:add_header("content-type", "text/plain") |
| 15 | applet:start_response() |
| 16 | applet:send(response) |
| 17 | end) |
| 18 | |
| 19 | core.register_service("http418-coffeepot", "http", function(applet) |
| 20 | local response = "Hello World !" |
| 21 | applet:set_status(418, "I'm a coffeepot") |
| 22 | applet:add_header("content-length", string.len(response)) |
| 23 | applet:add_header("content-type", "text/plain") |
| 24 | applet:start_response() |
| 25 | applet:send(response) |
| 26 | end) |