Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Servers/HAProxyServer/echo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ core.register_service("echo", "http", function(applet)
applet:start_response()
applet:send(body)
end)

core.register_service("echo_body", "http", function(applet)
local body = applet:receive()
if body == nil then body = "" end
applet:set_status(200)
applet:add_header("Content-Type", "text/plain")
applet:add_header("Content-Length", tostring(#body))
applet:start_response()
applet:send(body)
end)
4 changes: 4 additions & 0 deletions src/Servers/HAProxyServer/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ defaults
frontend http_in
bind *:8080
use_backend echo_backend if { path /echo }
use_backend post_echo_backend if { method POST }
http-request return status 200 content-type "text/plain" string "OK"

backend echo_backend
http-request use-service lua.echo

backend post_echo_backend
http-request use-service lua.echo_body