~sbaildon/caddy-regexp-replace

07e8d19c3030a3b54751680f7f004ca7eb932378 — Sean Baildon 2 months ago 881f0c9 main v0.1.0
_ -> -
2 files changed, 2 insertions(+), 2 deletions(-)

M README.md
M main.go
M README.md => README.md +1 -1
@@ 5,7 5,7 @@ amibitions to become a fully fledged caddy module
today, it's nothing more than a regex wrapper 

```go
regexp.MustCompile(`\.`).ReplaceAll(request.Host, []byte("_"))
regexp.MustCompile(`\.`).ReplaceAll(request.Host, []byte("-"))
```

## Use with Caddy

M main.go => main.go +1 -1
@@ 49,7 49,7 @@ func (m *Middleware) Provision(ctx caddy.Context) (err error) {
func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
	repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
	m.repl = repl
	replaced := m.compiled.ReplaceAll([]byte(r.Host), []byte("_"))
	replaced := m.compiled.ReplaceAll([]byte(r.Host), []byte("-"))

	m.repl.Set("http.regexp_replace.host", replaced)