File: setstatus.lua

package info (click to toggle)
haproxy 1.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,364 kB
  • ctags: 8,494
  • sloc: ansic: 92,976; xml: 1,754; sh: 1,227; python: 1,005; makefile: 831; perl: 550
file content (26 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- http-response actions
core.register_action("set-status-418-defaultreason", {"http-res"}, function(txn)
	txn.http:res_set_status(418)
end)
core.register_action("set-status-418-customreason", {"http-res"}, function(txn)
	txn.http:res_set_status(418, "I'm a coffeepot")
end)

-- http services
core.register_service("http418-default", "http", function(applet)
   local response = "Hello World !"
   applet:set_status(418)
   applet:add_header("content-length", string.len(response))
   applet:add_header("content-type", "text/plain")
   applet:start_response()
   applet:send(response)
end)

core.register_service("http418-coffeepot", "http", function(applet)
   local response = "Hello World !"
   applet:set_status(418, "I'm a coffeepot")
   applet:add_header("content-length", string.len(response))
   applet:add_header("content-type", "text/plain")
   applet:start_response()
   applet:send(response)
end)