Router FindByRequestURL() fix
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a27cc0624a
commit
6392d7088e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user