summaryrefslogtreecommitdiff
path: root/replacer.go
diff options
context:
space:
mode:
authorMark Sargent <99003+sarge@users.noreply.github.com>2020-06-27 09:12:37 +1200
committerGitHub <noreply@github.com>2020-06-26 15:12:37 -0600
commit6004d3f779b8175d92d8eb7819ed800e8eddbff6 (patch)
treea21b7e73d65f75656745c82b6792dca59be57b72 /replacer.go
parentcaca55e582c74e43338b270ebb5ff277c4404195 (diff)
caddyhttp: Add 'map' handler (#3199)
* inital map implementation * resolve the value during middleware execution * use regex instead * pr feedback * renamed mmap to maphandler * refactored GetString implementation * fixed mispelling * additional feedback
Diffstat (limited to 'replacer.go')
-rw-r--r--replacer.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/replacer.go b/replacer.go
index 86cd729..29d8e26 100644
--- a/replacer.go
+++ b/replacer.go
@@ -66,6 +66,13 @@ func (r *Replacer) Get(variable string) (interface{}, bool) {
return nil, false
}
+// GetString is the same as Get, but coerces the value to a
+// string representation.
+func (r *Replacer) GetString(variable string) (string, bool) {
+ s, found := r.Get(variable)
+ return toString(s), found
+}
+
// Delete removes a variable with a static value
// that was created using Set.
func (r *Replacer) Delete(variable string) {