mirror of
https://github.com/caddyserver/caddy.git
synced 2025-06-01 09:02:50 +08:00
Remove Starlark, for now
This is temporary as we prepare for a stable v2 release. We don't want to make promises we don't know we can keep, and the Starlark integration deserves much more focused attention which resources and funding do not currently permit. When the project is financially stable, I will be able to revisit this properly and add flexible, robust Starlark scripting support to Caddy 2.
This commit is contained in:
@ -28,8 +28,6 @@ import (
|
||||
|
||||
"github.com/caddyserver/caddy/v2"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
|
||||
"github.com/caddyserver/caddy/v2/pkg/caddyscript"
|
||||
"go.starlark.net/starlark"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -105,9 +103,6 @@ type (
|
||||
Matchers MatcherSet `json:"-"`
|
||||
}
|
||||
|
||||
// MatchStarlarkExpr matches requests by evaluating a Starlark expression.
|
||||
MatchStarlarkExpr string
|
||||
|
||||
// MatchTable matches requests by values in the table.
|
||||
MatchTable string // TODO: finish implementing
|
||||
)
|
||||
@ -123,7 +118,6 @@ func init() {
|
||||
caddy.RegisterModule(new(MatchProtocol))
|
||||
caddy.RegisterModule(MatchRemoteIP{})
|
||||
caddy.RegisterModule(MatchNegate{})
|
||||
caddy.RegisterModule(new(MatchStarlarkExpr))
|
||||
}
|
||||
|
||||
// CaddyModule returns the Caddy module information.
|
||||
@ -646,28 +640,6 @@ func (m MatchRemoteIP) Match(r *http.Request) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// CaddyModule returns the Caddy module information.
|
||||
func (MatchStarlarkExpr) CaddyModule() caddy.ModuleInfo {
|
||||
return caddy.ModuleInfo{
|
||||
ID: "http.matchers.starlark",
|
||||
New: func() caddy.Module { return new(MatchStarlarkExpr) },
|
||||
}
|
||||
}
|
||||
|
||||
// Match returns true if r matches m.
|
||||
func (m MatchStarlarkExpr) Match(r *http.Request) bool {
|
||||
input := string(m)
|
||||
thread := new(starlark.Thread)
|
||||
env := caddyscript.MatcherEnv(r)
|
||||
val, err := starlark.Eval(thread, "", input, env)
|
||||
if err != nil {
|
||||
// TODO: Can we detect this in Provision or Validate instead?
|
||||
log.Printf("caddyscript for matcher is invalid: attempting to evaluate expression `%v` error `%v`", input, err)
|
||||
return false
|
||||
}
|
||||
return val.String() == "True"
|
||||
}
|
||||
|
||||
// MatchRegexp is an embeddable type for matching
|
||||
// using regular expressions. It adds placeholders
|
||||
// to the request's replacer.
|
||||
@ -834,7 +806,6 @@ var (
|
||||
_ caddy.Provisioner = (*MatchRemoteIP)(nil)
|
||||
_ RequestMatcher = (*MatchNegate)(nil)
|
||||
_ caddy.Provisioner = (*MatchNegate)(nil)
|
||||
_ RequestMatcher = (*MatchStarlarkExpr)(nil)
|
||||
_ caddy.Provisioner = (*MatchRegexp)(nil)
|
||||
|
||||
_ caddyfile.Unmarshaler = (*MatchHost)(nil)
|
||||
|
Reference in New Issue
Block a user