fun: add BindRoute for custom HTTP routes (GET/POST, form-data callbacks)
- BindRoute(method, path, handler) with exact-match routing dispatched before /cell RPC - RouteCtx merges query args and form-urlencoded POST args for callback scenarios (e.g. epay notify) - handler returns error -> unified Result error response; nil -> full control via fasthttp.RequestCtx (plain-text 'success' replies) - /cell reserved; duplicate/invalid registration panics at startup; all existing tests pass
This commit is contained in:
@@ -10,9 +10,10 @@ import (
|
||||
|
||||
type Fun struct {
|
||||
methods map[string]methodInfo
|
||||
boxes *sync.Map // 依赖容器:reflect.Type → reflect.Value
|
||||
guards []*any // 全局 Guard
|
||||
serviceGuards map[string][]*any // 服务级 Guard,按服务名
|
||||
routes map[string]RouteHandler // 自定义路由:"GET /path" → 处理器
|
||||
boxes *sync.Map // 依赖容器:reflect.Type → reflect.Value
|
||||
guards []*any // 全局 Guard
|
||||
serviceGuards map[string][]*any // 服务级 Guard,按服务名
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -33,6 +34,7 @@ type methodInfo struct {
|
||||
func New() *Fun {
|
||||
f := &Fun{
|
||||
methods: map[string]methodInfo{},
|
||||
routes: map[string]RouteHandler{},
|
||||
boxes: &sync.Map{},
|
||||
serviceGuards: map[string][]*any{},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user