Skip to content

Commit 947fe96

Browse files
authored
Merge pull request #64 from MDA2AV/fix/haproxy
Fix HAProxy - POST /
2 parents 16e3add + 06da86d commit 947fe96

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/Servers/HAProxyServer/echo.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ core.register_service("echo", "http", function(applet)
1212
applet:start_response()
1313
applet:send(body)
1414
end)
15+
16+
core.register_service("echo_body", "http", function(applet)
17+
local body = applet:receive()
18+
if body == nil then body = "" end
19+
applet:set_status(200)
20+
applet:add_header("Content-Type", "text/plain")
21+
applet:add_header("Content-Length", tostring(#body))
22+
applet:start_response()
23+
applet:send(body)
24+
end)

src/Servers/HAProxyServer/haproxy.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ defaults
1111
frontend http_in
1212
bind *:8080
1313
use_backend echo_backend if { path /echo }
14+
use_backend post_echo_backend if { method POST }
1415
http-request return status 200 content-type "text/plain" string "OK"
1516

1617
backend echo_backend
1718
http-request use-service lua.echo
19+
20+
backend post_echo_backend
21+
http-request use-service lua.echo_body

0 commit comments

Comments
 (0)