mirror of
				https://github.com/labstack/echo.git
				synced 2025-10-30 23:57:38 +02:00 
			
		
		
		
	
							
								
								
									
										9
									
								
								echo.go
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								echo.go
									
									
									
									
									
								
							| @@ -471,7 +471,8 @@ func (e *Echo) add(method, path string, handler HandlerFunc, middleware ...Middl | ||||
| 		Path:    path, | ||||
| 		Handler: name, | ||||
| 	} | ||||
| 	e.router.routes = append(e.router.routes, r) | ||||
| 	e.router.routes[method+path] = r | ||||
| 	// e.router.routes = append(e.router.routes, r) | ||||
| } | ||||
|  | ||||
| // Group creates a new router group with prefix and optional group-level middleware. | ||||
| @@ -513,7 +514,11 @@ func (e *Echo) URL(h HandlerFunc, params ...interface{}) string { | ||||
|  | ||||
| // Routes returns the registered routes. | ||||
| func (e *Echo) Routes() []Route { | ||||
| 	return e.router.routes | ||||
| 	routes := []Route{} | ||||
| 	for _, v := range e.router.routes { | ||||
| 		routes = append(routes, v) | ||||
| 	} | ||||
| 	return routes | ||||
| } | ||||
|  | ||||
| // AcquireContext returns an empty `Context` instance from the pool. | ||||
|   | ||||
| @@ -5,7 +5,7 @@ type ( | ||||
| 	// request matching and URL path parameter parsing. | ||||
| 	Router struct { | ||||
| 		tree   *node | ||||
| 		routes []Route | ||||
| 		routes map[string]Route | ||||
| 		echo   *Echo | ||||
| 	} | ||||
| 	node struct { | ||||
| @@ -45,7 +45,7 @@ func NewRouter(e *Echo) *Router { | ||||
| 		tree: &node{ | ||||
| 			methodHandler: new(methodHandler), | ||||
| 		}, | ||||
| 		routes: []Route{}, | ||||
| 		routes: make(map[string]Route), | ||||
| 		echo:   e, | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user