docs: 弃用文档优化
This commit is contained in:
parent
10cc443b3a
commit
a0d5fc860a
|
@ -6,7 +6,8 @@ import (
|
|||
)
|
||||
|
||||
// NewLevel1Router 创建支持一级分类的路由器
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func NewLevel1Router[Route comparable, Handle any]() *Level1Router[Route, Handle] {
|
||||
return &Level1Router[Route, Handle]{
|
||||
routes: map[Route]Handle{},
|
||||
|
@ -14,12 +15,15 @@ func NewLevel1Router[Route comparable, Handle any]() *Level1Router[Route, Handle
|
|||
}
|
||||
|
||||
// Level1Router 支持一级分类的路由器
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
type Level1Router[Route comparable, Handle any] struct {
|
||||
routes map[Route]Handle
|
||||
}
|
||||
|
||||
// Route 创建路由
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func (slf *Level1Router[Route, Handle]) Route(route Route, handleFunc Handle) {
|
||||
if reflect.TypeOf(handleFunc).Kind() != reflect.Func {
|
||||
panic(fmt.Errorf("route[%v] registration failed, handle must be a function type", route))
|
||||
|
@ -32,7 +36,8 @@ func (slf *Level1Router[Route, Handle]) Route(route Route, handleFunc Handle) {
|
|||
}
|
||||
|
||||
// Match 匹配路由
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func (slf *Level1Router[Route, Handle]) Match(route Route) Handle {
|
||||
return slf.routes[route]
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ import (
|
|||
)
|
||||
|
||||
// NewLevel2Router 创建支持二级分类的路由器
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func NewLevel2Router[Route comparable, Handle any]() *Level2Router[Route, Handle] {
|
||||
return &Level2Router[Route, Handle]{
|
||||
routes: map[Route]map[Route]Handle{},
|
||||
|
@ -14,12 +15,15 @@ func NewLevel2Router[Route comparable, Handle any]() *Level2Router[Route, Handle
|
|||
}
|
||||
|
||||
// Level2Router 支持二级分类的路由器
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
type Level2Router[Route comparable, Handle any] struct {
|
||||
routes map[Route]map[Route]Handle
|
||||
}
|
||||
|
||||
// Route 创建路由
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func (slf *Level2Router[Route, Handle]) Route(topRoute Route, route Route, handleFunc Handle) {
|
||||
if reflect.TypeOf(handleFunc).Kind() != reflect.Func {
|
||||
panic(fmt.Errorf("route[%v] registration failed, handle must be a function type", route))
|
||||
|
@ -38,7 +42,8 @@ func (slf *Level2Router[Route, Handle]) Route(topRoute Route, route Route, handl
|
|||
}
|
||||
|
||||
// Match 匹配路由
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func (slf *Level2Router[Route, Handle]) Match(topRoute Route, route Route) Handle {
|
||||
return slf.routes[topRoute][route]
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ import (
|
|||
)
|
||||
|
||||
// NewLevel3Router 创建支持三级分类的路由器
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func NewLevel3Router[Route comparable, Handle any]() *Level3Router[Route, Handle] {
|
||||
return &Level3Router[Route, Handle]{
|
||||
routes: map[Route]map[Route]map[Route]Handle{},
|
||||
|
@ -14,13 +15,15 @@ func NewLevel3Router[Route comparable, Handle any]() *Level3Router[Route, Handle
|
|||
}
|
||||
|
||||
// Level3Router 支持三级分类的路由器
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
type Level3Router[Route comparable, Handle any] struct {
|
||||
routes map[Route]map[Route]map[Route]Handle
|
||||
}
|
||||
|
||||
// Route 创建路由
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func (slf *Level3Router[Route, Handle]) Route(topRoute Route, level2Route Route, route Route, handleFunc Handle) {
|
||||
if reflect.TypeOf(handleFunc).Kind() != reflect.Func {
|
||||
panic(fmt.Errorf("route[%v] registration failed, handle must be a function type", route))
|
||||
|
@ -43,7 +46,8 @@ func (slf *Level3Router[Route, Handle]) Route(topRoute Route, level2Route Route,
|
|||
}
|
||||
|
||||
// Match 匹配路由
|
||||
// - Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
//
|
||||
// Deprecated: 从 Minotaur 0.1.7 开始,由于该路由器设计不合理,局限性大,已弃用。建议使用 Multistage 进行代替。
|
||||
func (slf *Level3Router[Route, Handle]) Match(topRoute Route, level2Route Route, route Route) Handle {
|
||||
return slf.routes[topRoute][level2Route][route]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue