func (r *Replacer) ReplaceFunc(input string, f ReplacementFunc) (string, error) {
	return r.replace(input, "", true, false, false, f)
}
ReplaceFunc is the same as ReplaceAll, but calls f for every
replacement to be made, in case f wants to change or inspect
the replacement.
package caddy
import (
	"fmt"
	"os"
	"path/filepath"
	"runtime"
	"strconv"
	"strings"
	"time"
)
func NewReplacer() *Replacer {
	rep := &Replacer{
		static: make(map[string]interface{}),
	}
	rep.providers = []ReplacerFunc{
		globalDefaultReplacements,
		rep.fromStatic,
	}
	return rep
}
func NewEmptyReplacer() *Replacer {
	rep := &Replacer{
		static: make(map[string]interface{}),
	}
	rep.providers = []ReplacerFunc{
		rep.fromStatic,
	}
	return rep
}
type Replacer struct {
	providers []ReplacerFunc
	static    map[string]interface{}
}
func (r *Replacer) Map(mapFunc ReplacerFunc) {
	r.providers = append(r.providers, mapFunc)
}
func (r *Replacer) Set(variable string, value interface{}) {
	r.static[variable] = value
}
func (r *Replacer) Get(variable string) (interface{}, bool) {
	for _, mapFunc := range r.providers {
		if val, ok := mapFunc(variable); ok {
			return val, true
		}
	}
	return nil, false
}
func (r *Replacer) GetString(variable string) (string, bool) {
	s, found := r.Get(variable)
	return toString(s), found
}
func (r *Replacer) Delete(variable string) {
	delete(r.static, variable)
}
func (r *Replacer) fromStatic(key string) (interface{}, bool) {
	val, ok := r.static[key]
	return val, ok
}
func (r *Replacer) ReplaceOrErr(input string, errOnEmpty, errOnUnknown bool) (string, error) {
	return r.replace(input, "", false, errOnEmpty, errOnUnknown, nil)
}
func (r *Replacer) ReplaceKnown(input, empty string) string {
	out, _ := r.replace(input, empty, false, false, false, nil)
	return out
}
func (r *Replacer) ReplaceAll(input, empty string) string {
	out, _ := r.replace(input, empty, true, false, false, nil)
	return out
}