summaryrefslogtreecommitdiff
path: root/internal/caddyscript/matcherenv.go
diff options
context:
space:
mode:
authordev <navdgo@gmail.com>2019-04-03 11:47:27 -0400
committerdev <navdgo@gmail.com>2019-04-08 09:58:11 -0400
commit27ecc7f384bbfc98b28dc73881968897fb8c9a8a (patch)
tree1c579149528c26884c04e0daba3c9f320271b7a7 /internal/caddyscript/matcherenv.go
parent402f423693d86d3e37daf64f369dbf54f69338b3 (diff)
Protocol and Caddyscript matchers
* Added matcher to determine what protocol the request is being made by - grpc, tls, http * Added ability to run caddyscript in a matcher to evaluate the http request * Added TLS field to caddyscript request time * Added a library to manipulate and compare a new caddyscript time type * Library for regex in starlark
Diffstat (limited to 'internal/caddyscript/matcherenv.go')
-rw-r--r--internal/caddyscript/matcherenv.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/caddyscript/matcherenv.go b/internal/caddyscript/matcherenv.go
new file mode 100644
index 0000000..c6c8c0e
--- /dev/null
+++ b/internal/caddyscript/matcherenv.go
@@ -0,0 +1,18 @@
+package caddyscript
+
+import (
+ "net/http"
+
+ caddyscript "bitbucket.org/lightcodelabs/caddy2/internal/caddyscript/lib"
+ "go.starlark.net/starlark"
+)
+
+// MatcherEnv sets up the global context for the matcher caddyscript environment.
+func MatcherEnv(r *http.Request) starlark.StringDict {
+ env := make(starlark.StringDict)
+ env["req"] = caddyscript.HTTPRequest{Req: r}
+ env["time"] = caddyscript.Time{}
+ env["regexp"] = caddyscript.Regexp{}
+
+ return env
+}