aboutsummaryrefslogtreecommitdiffhomepage
path: root/dhall
diff options
context:
space:
mode:
authorPaul Bonaud <paul.bonaud@fretlink.com>2020-01-02 13:44:05 +0100
committerPaul Bonaud <paul.bonaud@fretlink.com>2020-01-02 15:41:41 +0100
commit5f23d5909f18ecc5d0af12cdbb1aee44dccf89ca (patch)
treebcf65ed77655f010e176186f9ffa75d1e575d0c2 /dhall
parent80320193527d24c33ce67da99521a4cdd6631edc (diff)
downloadansible-kong-app-5f23d5909f18ecc5d0af12cdbb1aee44dccf89ca.tar.gz
ansible-kong-app-5f23d5909f18ecc5d0af12cdbb1aee44dccf89ca.tar.zst
ansible-kong-app-5f23d5909f18ecc5d0af12cdbb1aee44dccf89ca.zip
config(dhall): add a pre-function lua definition for HTTPS redirects
This PR fixes #12 and takes precedence over #13 (cherry-picked one of #13's commit)
Diffstat (limited to 'dhall')
-rw-r--r--dhall/functions.dhall1
-rw-r--r--dhall/server/service/plugin/functions.dhall1
-rw-r--r--dhall/server/service/plugin/http2httpsRedirect.dhall15
-rw-r--r--dhall/types.dhall13
4 files changed, 16 insertions, 14 deletions
diff --git a/dhall/functions.dhall b/dhall/functions.dhall
deleted file mode 100644
index 6465760..0000000
--- a/dhall/functions.dhall
+++ /dev/null
@@ -1 +0,0 @@
1{ Server = ./server/functions.dhall }
diff --git a/dhall/server/service/plugin/functions.dhall b/dhall/server/service/plugin/functions.dhall
index a7b1295..098fba7 100644
--- a/dhall/server/service/plugin/functions.dhall
+++ b/dhall/server/service/plugin/functions.dhall
@@ -3,4 +3,5 @@
3, mkIPRestriction = ./mkIPRestriction.dhall 3, mkIPRestriction = ./mkIPRestriction.dhall
4, correlationId = ./correlationId.dhall 4, correlationId = ./correlationId.dhall
5, mkPreFunction = ./mkPreFunction.dhall 5, mkPreFunction = ./mkPreFunction.dhall
6, http2httpsRedirect = ./http2httpsRedirect.dhall
6} 7}
diff --git a/dhall/server/service/plugin/http2httpsRedirect.dhall b/dhall/server/service/plugin/http2httpsRedirect.dhall
new file mode 100644
index 0000000..faa6d79
--- /dev/null
+++ b/dhall/server/service/plugin/http2httpsRedirect.dhall
@@ -0,0 +1,15 @@
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 ]
diff --git a/dhall/types.dhall b/dhall/types.dhall
deleted file mode 100644
index 938dc74..0000000
--- a/dhall/types.dhall
+++ /dev/null
@@ -1,13 +0,0 @@
1{ Vault =
2 ./Vault.dhall
3, Config =
4 ./Config.dhall
5, Server =
6 ./server/Server.dhall
7, Service =
8 ./server/service/Service.dhall
9, Plugin =
10 ./server/service/plugin/Plugin.dhall
11, Route =
12 ./server/service/route/Route.dhall
13}