0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-30 22:34:15 -05:00
caddy/modules/caddyhttp/starlarkmw/example/caddy.json
Matthew Holt 26cc883708
http: Add Starlark handler
This migrates a feature that was previously reserved for enterprise
users, according to #2786.

The Starlark integration needs to be updated since this was made before
some significant changes in the v2 code base. When functional, it makes
it possible to have very dynamic HTTP handlers. This will be a long-term
ongoing project.

Credit to Danny Navarro
2019-10-10 11:02:16 -06:00

19 lines
No EOL
483 B
JSON

{
"apps": {
"http": {
"servers": {
"MY_SERVER": {
"listen": [":3001"],
"routes": [
{
"handle": {
"handler": "starlark",
"script": "def setup(r):\n\t# create some middlewares specific to this request\n\ttemplates = loadModule('http.handlers.templates', {'include_root': './includes'})\n\tmidChain = execute([templates])\n\ndef serveHTTP (rw, r):\n\trw.Write('Hello world, from Starlark!')\n"
}
}
]
}
}
}
}
}