Closed diyism closed 2 years ago
You can write a custom module which would let you do this: https://caddyserver.com/docs/extending-caddy
But you'd probably be better off just what your script in Go instead of delegating it to a script.
We had plans early on in the development of Caddy v2 to use Starlark for scripting, but with how easy modules are to write, it hasn't been a priority to implement scripting support.
Related issue https://github.com/caddyserver/caddy/issues/2690
Yeah, we still like the idea of a Starlark module, but decided it doesn't have to be baked in -- and it's a lot of work -- so we deprioritized it; but that doesn't mean you can't write your own module for something like dynamic scripts!
Nowadays, I'm still dreaming of a caddy module that supports tengo script, in my dream: the best golang web server(caddy) + the best golang script language(tengo) + the best web page template(svelte, currently the golang version(plenti) is not as fast as the bun/node version(svelte-bun) https://github.com/xyproto/algernon/issues/125 )
Why not just write a Caddy plugin for what you need? It's trivial, and building is very easy with xcaddy
.
Or, just write the Tengo plugin yourself, it shouldn't be too hard.
We have no plans to work on this because we don't have a need for it, the cost-benefit ratio is not good enough for us to spend time on this when we could focus on other things.
I don't think it's a priority for us right now for the reasons Francis mentioned, but I could work on it with a suitable sponsorship. Or, of course anyone else is welcome to implement it themselves in the meantime. 👍
Thanks, I'll give a try to build a tengo caddy plugin.
Cool! Please share it with us and the community once you have it :grinning:
I know that the algernon web server can run gopher-lua script (https://github.com/xyproto/algernon)
How to let caddy server to run tengo script to serve a web site? (https://github.com/d5/tengo)
Or Is there any other golang script supported by caddy server?