aboutsummaryrefslogtreecommitdiffhomepage
path: root/dhall
diff options
context:
space:
mode:
authorpaulrbr-fl <43074087+paulrbr-fl@users.noreply.github.com>2020-01-02 16:25:37 +0100
committerGitHub <noreply@github.com>2020-01-02 16:25:37 +0100
commit25250c8c24a3c0b32c92eee5552ad7156115f03c (patch)
tree02c178a19be0e233813600531c85ef7ad5e4c51c /dhall
parent027a2fa61a6044b2e967b29195312e4d98a96078 (diff)
parenta3c4b3d5444e5d79afbd823a9acc12220a91f41f (diff)
downloadansible-kong-app-25250c8c24a3c0b32c92eee5552ad7156115f03c.tar.gz
ansible-kong-app-25250c8c24a3c0b32c92eee5552ad7156115f03c.tar.zst
ansible-kong-app-25250c8c24a3c0b32c92eee5552ad7156115f03c.zip
Merge pull request #18 from paulrbr-fl/pre-function-pluginsv0.30
config(dhall): add a pre-function lua definition for HTTPS redirects
Diffstat (limited to 'dhall')
-rw-r--r--dhall/functions.dhall1
-rw-r--r--dhall/server/service/plugin/Config.dhall11
-rw-r--r--dhall/server/service/plugin/functions.dhall7
-rw-r--r--dhall/server/service/plugin/http2httpsRedirect.dhall15
-rw-r--r--dhall/server/service/plugin/mkPreFunction.dhall9
-rw-r--r--dhall/server/service/plugin/package.dhall7
-rw-r--r--dhall/types.dhall13
7 files changed, 37 insertions, 26 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/Config.dhall b/dhall/server/service/plugin/Config.dhall
index ea53361..1f60080 100644
--- a/dhall/server/service/plugin/Config.dhall
+++ b/dhall/server/service/plugin/Config.dhall
@@ -1,9 +1,8 @@
1< CorrelationId : 1< CorrelationId :
2 { header_name : Text, echo_downstream : Bool, generator : Text } 2 { header_name : Text, echo_downstream : Bool, generator : Text }
3| RequestTransformer : 3| RequestTransformer : { add : { headers : List Text } }
4 { add : { headers : List Text } }
5| RequestTermination : 4| RequestTermination :
6 { status_code : Natural, content_type : Text, body : Text } 5 { status_code : Natural, content_type : Text, body : Text }
7| IPRestriction : 6| IPRestriction : { whitelist : Text }
8 { whitelist : Text } 7| PreFunction : { functions : List Text }
9> 8>
diff --git a/dhall/server/service/plugin/functions.dhall b/dhall/server/service/plugin/functions.dhall
new file mode 100644
index 0000000..098fba7
--- /dev/null
+++ b/dhall/server/service/plugin/functions.dhall
@@ -0,0 +1,7 @@
1{ mkRequestTermination = ./mkRequestTermination.dhall
2, mkRequestTransformer = ./mkRequestTransformer.dhall
3, mkIPRestriction = ./mkIPRestriction.dhall
4, correlationId = ./correlationId.dhall
5, mkPreFunction = ./mkPreFunction.dhall
6, http2httpsRedirect = ./http2httpsRedirect.dhall
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/server/service/plugin/mkPreFunction.dhall b/dhall/server/service/plugin/mkPreFunction.dhall
new file mode 100644
index 0000000..ff4f734
--- /dev/null
+++ b/dhall/server/service/plugin/mkPreFunction.dhall
@@ -0,0 +1,9 @@
1let Plugin = ./Plugin.dhall
2
3let config = ./Config.dhall
4
5in λ(functions : List Text)
6 → { name = "pre-function"
7 , config = config.PreFunction { functions = functions }
8 }
9 : Plugin
diff --git a/dhall/server/service/plugin/package.dhall b/dhall/server/service/plugin/package.dhall
index 872c53b..c231bc6 100644
--- a/dhall/server/service/plugin/package.dhall
+++ b/dhall/server/service/plugin/package.dhall
@@ -1,6 +1 @@
1{ Type = ./Plugin.dhall { Type = ./Plugin.dhall, functions = ./functions.dhall }
2, mkRequestTermination = ./mkRequestTermination.dhall
3, mkRequestTransformer = ./mkRequestTransformer.dhall
4, mkIPRestriction = ./mkIPRestriction.dhall
5, correlationId = ./correlationId.dhall
6}
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}