diff options
Diffstat (limited to 'dhall/server')
-rw-r--r-- | dhall/server/service/plugin/functions.dhall | 1 | ||||
-rw-r--r-- | dhall/server/service/plugin/http2httpsRedirect.dhall | 15 |
2 files changed, 16 insertions, 0 deletions
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 @@ | |||
1 | let mkPreFunction = ./mkPreFunction.dhall | ||
2 | |||
3 | let 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 | |||
15 | in mkPreFunction [ luaRedirect ] | ||