aboutsummaryrefslogtreecommitdiff
path: root/example/api/reluax.luax
blob: cae3d33d1ac179d895ad5d9bd4d4c858c3ddcf11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local message = "default"

local route = function(path, method, body)
  if path ~= "/api/example" then
    return 404, reluax.json { message = "Not Found" }
  end

  if method == "GET" then
    return 200, reluax.json { message = message }
  elseif method == "POST" then
    message = body
    return 200, reluax.json { message = message }
  end

  return 400, reluax.json { message = "Bad Request" }
end

return {
  name = "api-example",
  route = route
}