diff --git a/pkg/server/router.go b/pkg/server/router.go index 0ee04f3..a7b9eb7 100644 --- a/pkg/server/router.go +++ b/pkg/server/router.go @@ -38,6 +38,14 @@ func NewRouter(config *config.Config, ds *cache.MemoryDatastore, ttl int) *Route func (r *Router) FindByRequestURL(url []byte) (bool, *cache.RouteCache) { var sURL = string(url) + //if cRoute, ok := r.cache[sURL]; ok { + if cRoute, err := r.cache.GetKey("route_" + sURL); err == nil { + return true, cRoute.(*cache.RouteCache) + //response := &cache.RouteCache{} // FIXME #67: Simplify + //ffjson.Unmarshal([]byte(cRoute.(string)), response) + //return true, response // FIXME: redis cache tmp + } + for bID := range r.config.Backends { bck := r.config.Backends[bID] if !strings.Contains(sURL, bck.PrefixURL) { @@ -47,14 +55,6 @@ func (r *Router) FindByRequestURL(url []byte) (bool, *cache.RouteCache) { for rID := range bck.Routes { rCfg := &bck.Routes[rID] - //if cRoute, ok := r.cache[sURL]; ok { - if cRoute, err := r.cache.GetKey("route_" + sURL); err == nil { - return true, cRoute.(*cache.RouteCache) - //response := &cache.RouteCache{} // FIXME #67: Simplify - //ffjson.Unmarshal([]byte(cRoute.(string)), response) - //return true, response // FIXME: redis cache tmp - } - regxp := regexp.MustCompile(fmt.Sprintf("%s%s", bck.PrefixURL, rCfg.Pattern)) if regxp.Match(url) { tURL := bck.BackendAddress + regxp.ReplaceAllString(sURL, rCfg.Target)