aboutsummaryrefslogtreecommitdiffhomepage
path: root/dhall/server/service/plugin/http2httpsRedirect.dhall
blob: faa6d79ef50342ff829fd79e9ff5bbcbfbc575f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
let mkPreFunction = ./mkPreFunction.dhall

let luaRedirect =
      ''
      local scheme = kong.request.get_scheme()
      if scheme == "http" then
        local host = kong.request.get_host()
        local query = kong.request.get_path_with_query()
        local url = "https://" .. host ..query
        kong.response.set_header("Location", url)
        return kong.response.exit(301, url)
      end
      ''

in  mkPreFunction [ luaRedirect ]