From c32b038da2350f4e23a4e6faaab6a0798777e032 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 16 Mar 2020 09:26:10 +0100 Subject: [PATCH] make splitURL public --- internal/config/func.go | 4 ++-- internal/config/server.go | 4 ++-- internal/config/service.go | 6 +++--- internal/config/types.go | 6 ------ 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/internal/config/func.go b/internal/config/func.go index 2d7f479..674030c 100644 --- a/internal/config/func.go +++ b/internal/config/func.go @@ -2,8 +2,8 @@ package config import "strings" -// splits an URL without empty sets -func splitURL(url string) []string { +// SplitURL without empty sets +func SplitURL(url string) []string { trimmed := strings.Trim(url, " /\t\r\n") split := strings.Split(trimmed, "/") diff --git a/internal/config/server.go b/internal/config/server.go index 96f3cbd..b197ee0 100644 --- a/internal/config/server.go +++ b/internal/config/server.go @@ -55,8 +55,8 @@ func (server *Server) collide() error { continue } - aParts := splitURL(aService.Pattern) - bParts := splitURL(bService.Pattern) + aParts := SplitURL(aService.Pattern) + bParts := SplitURL(bService.Pattern) // not same size if len(aParts) != len(bParts) { diff --git a/internal/config/service.go b/internal/config/service.go index 4edc764..90d6a1f 100644 --- a/internal/config/service.go +++ b/internal/config/service.go @@ -54,7 +54,7 @@ func (svc *Service) checkPattern() error { } // for each slash-separated chunk - parts := splitURL(svc.Pattern) + parts := SplitURL(svc.Pattern) for i, part := range parts { if len(part) < 1 { return ErrInvalidPattern @@ -154,8 +154,8 @@ func (svc *Service) checkAndFormatInput(types []datatype.T) error { // checks if an uri matches the service's pattern func (svc *Service) matchPattern(uri string) bool { - uriparts := splitURL(uri) - parts := splitURL(svc.Pattern) + uriparts := SplitURL(uri) + parts := SplitURL(svc.Pattern) // fail if size differ if len(uriparts) != len(parts) { diff --git a/internal/config/types.go b/internal/config/types.go index 9e2c9bf..c76e36a 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -45,9 +45,3 @@ type BraceCapture struct { Index int Ref *Parameter } - -// links to the related URI parameter and hold a value -type braceCaptureValue struct { - BraceCapture - Value interface{} -}