From 77e27a11c31fee82c2ff30613bc832f5171fa845 Mon Sep 17 00:00:00 2001 From: Hussein Ait-Lahcen Date: Mon, 19 Nov 2018 15:51:21 +0100 Subject: add dhall interface --- dhall/server/service/plugin/Config.dhall | 9 +++++++++ dhall/server/service/plugin/CorrelationId.dhall | 11 +++++++++++ dhall/server/service/plugin/Plugin.dhall | 1 + dhall/server/service/plugin/functions.dhall | 9 +++++++++ dhall/server/service/plugin/mkIPRestriction.dhall | 11 +++++++++++ .../server/service/plugin/mkRequestTermination.dhall | 20 ++++++++++++++++++++ .../server/service/plugin/mkRequestTransformer.dhall | 11 +++++++++++ 7 files changed, 72 insertions(+) create mode 100644 dhall/server/service/plugin/Config.dhall create mode 100644 dhall/server/service/plugin/CorrelationId.dhall create mode 100644 dhall/server/service/plugin/Plugin.dhall create mode 100644 dhall/server/service/plugin/functions.dhall create mode 100644 dhall/server/service/plugin/mkIPRestriction.dhall create mode 100644 dhall/server/service/plugin/mkRequestTermination.dhall create mode 100644 dhall/server/service/plugin/mkRequestTransformer.dhall (limited to 'dhall/server/service/plugin') diff --git a/dhall/server/service/plugin/Config.dhall b/dhall/server/service/plugin/Config.dhall new file mode 100644 index 0000000..73a333f --- /dev/null +++ b/dhall/server/service/plugin/Config.dhall @@ -0,0 +1,9 @@ +< CorrelationId : + { header_name : Text, echo_downstream : Bool } +| RequestTransformer : + { `add.headers` : Text } +| RequestTermination : + { status_code : Natural, content_type : Text, body : Text } +| IPRestriction : + { whitelist : Text } +> diff --git a/dhall/server/service/plugin/CorrelationId.dhall b/dhall/server/service/plugin/CorrelationId.dhall new file mode 100644 index 0000000..d96bfc9 --- /dev/null +++ b/dhall/server/service/plugin/CorrelationId.dhall @@ -0,0 +1,11 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in { name = + "correlation-id" + , config = + config.CorrelationId + { header_name = "X-correl", echo_downstream = True } + } + : Plugin diff --git a/dhall/server/service/plugin/Plugin.dhall b/dhall/server/service/plugin/Plugin.dhall new file mode 100644 index 0000000..548061c --- /dev/null +++ b/dhall/server/service/plugin/Plugin.dhall @@ -0,0 +1 @@ +let Config = ./Config.dhall in { name : Text, config : Config } diff --git a/dhall/server/service/plugin/functions.dhall b/dhall/server/service/plugin/functions.dhall new file mode 100644 index 0000000..dcf2c9a --- /dev/null +++ b/dhall/server/service/plugin/functions.dhall @@ -0,0 +1,9 @@ +{ mkRequestTermination = + ./mkRequestTermination.dhall +, mkRequestTransformer = + ./mkRequestTransformer.dhall +, mkIPRestriction = + ./mkIPRestriction.dhall +, CorrelationId = + ./CorrelationId.dhall +} diff --git a/dhall/server/service/plugin/mkIPRestriction.dhall b/dhall/server/service/plugin/mkIPRestriction.dhall new file mode 100644 index 0000000..f803769 --- /dev/null +++ b/dhall/server/service/plugin/mkIPRestriction.dhall @@ -0,0 +1,11 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in λ(whiteList : Text) + → { name = + "ip-restriction" + , config = + config.IPRestriction { whitelist = whiteList } + } + : Plugin diff --git a/dhall/server/service/plugin/mkRequestTermination.dhall b/dhall/server/service/plugin/mkRequestTermination.dhall new file mode 100644 index 0000000..aff538f --- /dev/null +++ b/dhall/server/service/plugin/mkRequestTermination.dhall @@ -0,0 +1,20 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in λ(statusCode : Natural) + → λ(contentType : Text) + → λ(body : Text) + → { name = + "request-termination" + , config = + config.RequestTermination + { status_code = + statusCode + , content_type = + contentType + , body = + body + } + } + : Plugin diff --git a/dhall/server/service/plugin/mkRequestTransformer.dhall b/dhall/server/service/plugin/mkRequestTransformer.dhall new file mode 100644 index 0000000..90789c8 --- /dev/null +++ b/dhall/server/service/plugin/mkRequestTransformer.dhall @@ -0,0 +1,11 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in λ(header : Text) + → { name = + "request-transformer" + , config = + config.RequestTransformer { `add.headers` = header } + } + : Plugin -- cgit v1.2.3