Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inquiry on Using Starlark Scripting with Caddy #6325

Closed
zong62296 opened this issue May 18, 2024 · 4 comments
Closed

Inquiry on Using Starlark Scripting with Caddy #6325

zong62296 opened this issue May 18, 2024 · 4 comments
Labels
question ❔ Help is being requested

Comments

@zong62296
Copy link

I recently came across the capability of using Starlark scripting with Caddy and am quite intrigued by the prospects it opens up for customizing and extending functionality. However, I've had a difficult time finding comprehensive documentation or examples on how to properly utilize Starlark scripts within the Caddy ecosystem.

Could you please provide guidance or point me to resources on the following:

  1. Getting Started with Starlark in Caddy: Any initial steps or prerequisites required to start using Starlark scripts with Caddy.

  2. Example Scripts: If possible, a few example Starlark scripts that demonstrate basic to intermediate usage within Caddy. This could include examples of modifying requests/responses, routing logic, or any other common use cases.

  3. Best Practices: Any best practices or recommendations when scripting with Starlark in the context of Caddy. This might include performance considerations, security practices, or common patterns.

  4. Troubleshooting and Debugging: Tips on how to troubleshoot and debug Starlark scripts when things don't go as expected.

I am quite excited about the potential to leverage Starlark to tailor my Caddy setup more closely to my needs but want to ensure I'm using it effectively and appropriately.

Thank you for any information or insights you can provide!

@mholt
Copy link
Member

mholt commented May 18, 2024

I recently came across the capability of using Starlark scripting with Caddy

This was discussed at one time, about 5 years ago, but as far as I know never came to fruition. Where did you find the capability?

@zong62296
Copy link
Author

@mholt On the Starlark official repo: https://github.com/bazelbuild/starlark/blob/master/users.md

@zong62296
Copy link
Author

It said that ---

Caddy is a fast, cross-platform HTTP/2 web server with automatic HTTPS. Starlark is used in Caddy 2 to extend the JSON configuration and add some logic.

@francislavoie
Copy link
Member

francislavoie commented May 18, 2024

Ah, no that's not true. We gave up on it because writing Caddy plugins in Go is so easy and doesn't require any additional work from us to provide (since Caddy was designed to be modular from the ground up). https://caddyserver.com/docs/extending-caddy

We are using https://github.com/google/cel-go though which is an embedded language, which allows for matching requests using a complex boolean expression. See https://caddyserver.com/docs/caddyfile/matchers#expression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❔ Help is being requested
Projects
None yet
Development

No branches or pull requests

3 participants