mirror of
https://github.com/caddyserver/caddy.git
synced 2025-06-03 21:54:29 -04:00
Export Replacer type
This commit is contained in:
parent
082ae70d1d
commit
a28d5585f5
@ -8,17 +8,21 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// replacer is a type which can replace placeholder
|
// Replacer is a type which can replace placeholder
|
||||||
// substrings in a string with actual values from a
|
// substrings in a string with actual values from a
|
||||||
// http.Request and responseRecorder. Always use
|
// http.Request and responseRecorder. Always use
|
||||||
// NewReplacer to get one of these.
|
// NewReplacer to get one of these.
|
||||||
|
type Replacer interface {
|
||||||
|
Replace(string) string
|
||||||
|
}
|
||||||
|
|
||||||
type replacer map[string]string
|
type replacer map[string]string
|
||||||
|
|
||||||
// NewReplacer makes a new replacer based on r and rr.
|
// NewReplacer makes a new replacer based on r and rr.
|
||||||
// Do not create a new replacer until r and rr have all
|
// Do not create a new replacer until r and rr have all
|
||||||
// the needed values, because this function copies those
|
// the needed values, because this function copies those
|
||||||
// values into the replacer.
|
// values into the replacer.
|
||||||
func NewReplacer(r *http.Request, rr *responseRecorder) replacer {
|
func NewReplacer(r *http.Request, rr *responseRecorder) Replacer {
|
||||||
rep := replacer{
|
rep := replacer{
|
||||||
"{method}": r.Method,
|
"{method}": r.Method,
|
||||||
"{scheme}": func() string {
|
"{scheme}": func() string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user