From 6004d3f779b8175d92d8eb7819ed800e8eddbff6 Mon Sep 17 00:00:00 2001 From: Mark Sargent <99003+sarge@users.noreply.github.com> Date: Sat, 27 Jun 2020 09:12:37 +1200 Subject: 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 --- replacer.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'replacer.go') 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) { -- cgit v1.2.3