make splitURL public
This commit is contained in:
parent
1b4922693b
commit
c32b038da2
|
@ -2,8 +2,8 @@ package config
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
// splits an URL without empty sets
|
// SplitURL without empty sets
|
||||||
func splitURL(url string) []string {
|
func SplitURL(url string) []string {
|
||||||
trimmed := strings.Trim(url, " /\t\r\n")
|
trimmed := strings.Trim(url, " /\t\r\n")
|
||||||
split := strings.Split(trimmed, "/")
|
split := strings.Split(trimmed, "/")
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ func (server *Server) collide() error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
aParts := splitURL(aService.Pattern)
|
aParts := SplitURL(aService.Pattern)
|
||||||
bParts := splitURL(bService.Pattern)
|
bParts := SplitURL(bService.Pattern)
|
||||||
|
|
||||||
// not same size
|
// not same size
|
||||||
if len(aParts) != len(bParts) {
|
if len(aParts) != len(bParts) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (svc *Service) checkPattern() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for each slash-separated chunk
|
// for each slash-separated chunk
|
||||||
parts := splitURL(svc.Pattern)
|
parts := SplitURL(svc.Pattern)
|
||||||
for i, part := range parts {
|
for i, part := range parts {
|
||||||
if len(part) < 1 {
|
if len(part) < 1 {
|
||||||
return ErrInvalidPattern
|
return ErrInvalidPattern
|
||||||
|
@ -154,8 +154,8 @@ func (svc *Service) checkAndFormatInput(types []datatype.T) error {
|
||||||
|
|
||||||
// checks if an uri matches the service's pattern
|
// checks if an uri matches the service's pattern
|
||||||
func (svc *Service) matchPattern(uri string) bool {
|
func (svc *Service) matchPattern(uri string) bool {
|
||||||
uriparts := splitURL(uri)
|
uriparts := SplitURL(uri)
|
||||||
parts := splitURL(svc.Pattern)
|
parts := SplitURL(svc.Pattern)
|
||||||
|
|
||||||
// fail if size differ
|
// fail if size differ
|
||||||
if len(uriparts) != len(parts) {
|
if len(uriparts) != len(parts) {
|
||||||
|
|
|
@ -45,9 +45,3 @@ type BraceCapture struct {
|
||||||
Index int
|
Index int
|
||||||
Ref *Parameter
|
Ref *Parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
// links to the related URI parameter and hold a value
|
|
||||||
type braceCaptureValue struct {
|
|
||||||
BraceCapture
|
|
||||||
Value interface{}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue