diff options
author | Matt Holt <mholt@users.noreply.github.com> | 2019-10-10 11:27:45 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-10 11:27:45 -0600 |
commit | b38365ff3b6ab8b2c474603fa0603831e7eff2a7 (patch) | |
tree | 7a35ea901e4ce8d3fbe028e8fc81bd1f69c6be68 /modules/caddyhttp/starlarkmw/tools/gen | |
parent | 53dd600b4de0c2b169f1eb4450a0f02950912524 (diff) | |
parent | 26cc8837084f9cea6057e9908f0b5bde0eb15d3e (diff) |
Merge pull request #2799 from caddyserver/v2-enterprise-merge
v2: Merge enterprise code into open source v2 branch
Diffstat (limited to 'modules/caddyhttp/starlarkmw/tools/gen')
-rw-r--r-- | modules/caddyhttp/starlarkmw/tools/gen/example.star | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/caddyhttp/starlarkmw/tools/gen/example.star b/modules/caddyhttp/starlarkmw/tools/gen/example.star new file mode 100644 index 0000000..6ccab32 --- /dev/null +++ b/modules/caddyhttp/starlarkmw/tools/gen/example.star @@ -0,0 +1,40 @@ +# any module that provisions resources +proxyConfig = { + 'load_balance_type': 'round_robin', + 'upstreams': [ + { + 'host': 'http://localhost:8080', + 'circuit_breaker': { + 'type': 'status_ratio', + 'threshold': 0.5 + } + }, + { + 'host': 'http://localhost:8081' + } + ] +} + +sfConfig = { + 'root': '/Users/dev/Desktop', + 'browse': {}, +} + +proxy = loadResponder('reverse_proxy', proxyConfig) +static_files = loadResponder('file_server', sfConfig) + +def setup(r): + # create some middlewares specific to this request + mid = [] + + if r.query.get('log') == 'true': + logMid = loadMiddleware('log', {'file': 'access.log'}) + mid.append(logMid) + + execute(mid) + +def serveHTTP(w, r): + if r.url.find('static') > 0: + return static_files + + return proxy |