From 1b944bf1c4c321b165a409043ce783baed787b2d Mon Sep 17 00:00:00 2001 From: fanste Date: Thu, 7 Mar 2019 18:09:17 +0100 Subject: [PATCH] Add replacement variable "hostonly" Could be useful in combination with reverse proxy to replace the host dynamically but let the port be static --- ruleReplaceAction.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ruleReplaceAction.go b/ruleReplaceAction.go index c6a6f93..3d49d2e 100644 --- a/ruleReplaceAction.go +++ b/ruleReplaceAction.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" "time" + "net" ) var paramReplacementPattern = regexp.MustCompile("\\{[a-zA-Z0-9_\\-.]+}") @@ -87,6 +88,12 @@ func (instance *ruleReplaceAction) contextRequestValueBy(name string) (string, b return request.Method, true case "host": return request.Host, true + case "hostonly": + host, _, err := net.SplitHostPort(request.Host) + if err != nil { + return request.Host, true + } + return host, true case "proto": return request.Proto, true case "remoteAddress":