Improved route order flexibility
This commit is contained in:
parent
00bab0323b
commit
59c0a95a89
4 changed files with 99 additions and 5 deletions
|
@ -1,5 +1,7 @@
|
|||
package router
|
||||
|
||||
import "os"
|
||||
|
||||
// Router is a high-performance router.
|
||||
type Router[T comparable] struct {
|
||||
get Tree[T]
|
||||
|
@ -57,6 +59,12 @@ func (router *Router[T]) Bind(transform func(T) T) {
|
|||
router.options.Bind(transform)
|
||||
}
|
||||
|
||||
// Print shows a pretty print of all the routes.
|
||||
func (router *Router[T]) Print(method string) {
|
||||
tree := router.selectTree(method)
|
||||
tree.root.PrettyPrint(os.Stdout)
|
||||
}
|
||||
|
||||
// selectTree returns the tree by the given HTTP method.
|
||||
func (router *Router[T]) selectTree(method string) *Tree[T] {
|
||||
switch method {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue