diff --git a/api/api.go b/api/api.go index b74952d0..14288158 100644 --- a/api/api.go +++ b/api/api.go @@ -60,22 +60,6 @@ type Service struct { Services []*registry.Service } -func strip(s string) string { - return strings.TrimSpace(s) -} - -func slice(s string) []string { - var sl []string - - for _, p := range strings.Split(s, ",") { - if str := strip(p); len(str) > 0 { - sl = append(sl, strip(p)) - } - } - - return sl -} - // Encode encodes an endpoint to endpoint metadata func Encode(e *Endpoint) map[string]string { if e == nil { @@ -152,28 +136,6 @@ func Validate(e *Endpoint) error { return nil } -/* -Design ideas - -// Gateway is an api gateway interface -type Gateway interface { - // Register a http handler - Handle(pattern string, http.Handler) - // Register a route - RegisterRoute(r Route) - // Init initialises the command line. - // It also parses further options. - Init(...Option) error - // Run the gateway - Run() error -} - -// NewGateway returns a new api gateway -func NewGateway() Gateway { - return newGateway() -} -*/ - // WithEndpoint returns a server.HandlerOption with endpoint metadata set // // Usage: diff --git a/api/util.go b/api/util.go new file mode 100644 index 00000000..49d849e7 --- /dev/null +++ b/api/util.go @@ -0,0 +1,21 @@ +package api + +import ( + "strings" +) + +func strip(s string) string { + return strings.TrimSpace(s) +} + +func slice(s string) []string { + var sl []string + + for _, p := range strings.Split(s, ",") { + if str := strip(p); len(str) > 0 { + sl = append(sl, strip(p)) + } + } + + return sl +}