]> git.immae.eu Git - github/fretlink/ansible-kong-app.git/blame - dhall/server/service/plugin/http2httpsRedirect.dhall
config(dhall): add a pre-function lua definition for HTTPS redirects
[github/fretlink/ansible-kong-app.git] / dhall / server / service / plugin / http2httpsRedirect.dhall
CommitLineData
5f23d590
PB
1let mkPreFunction = ./mkPreFunction.dhall
2
3let luaRedirect =
4 ''
5 local scheme = kong.request.get_scheme()
6 if scheme == "http" then
7 local host = kong.request.get_host()
8 local query = kong.request.get_path_with_query()
9 local url = "https://" .. host ..query
10 kong.response.set_header("Location", url)
11 return kong.response.exit(301, url)
12 end
13 ''
14
15in mkPreFunction [ luaRedirect ]