feat(web): Go W-G10 proxy and invoke route bags
Register web_app_proxy/invoke and merge configure tables into proxy_routes/invoke_routes so offline proxy-invoke smoke passes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
695939ac74
commit
56df0736fa
8 files changed
+705
-1
No files matched your search
@@ -7,6 +7,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/invoke"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/proxy"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/table"
|
||||
)
|
||||
|
||||
@@ -76,9 +78,30 @@ func Configure(appBag map[string]any, args map[string]any) (map[string]any, erro
|
||||
mw["json_routes"] = JSONRoutesFromTable(v)
|
||||
}
|
||||
out["middleware"] = mw
|
||||
|
||||
if v, ok := first(args, "proxy", "proxy_routes", "代理"); ok && v != nil {
|
||||
mergeRouteMap(out, "proxy_routes", proxy.RoutesFromTable(v))
|
||||
}
|
||||
if v, ok := first(args, "invoke", "invoke_routes", "调用"); ok && v != nil {
|
||||
mergeRouteMap(out, "invoke_routes", invoke.RoutesFromTable(v))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func mergeRouteMap(appBag map[string]any, key string, incoming map[string]any) {
|
||||
if len(incoming) == 0 {
|
||||
return
|
||||
}
|
||||
existing := map[string]any{}
|
||||
if r, ok := appBag[key].(map[string]any); ok {
|
||||
existing = clone(r)
|
||||
}
|
||||
for k, v := range incoming {
|
||||
existing[k] = v
|
||||
}
|
||||
appBag[key] = existing
|
||||
}
|
||||
|
||||
// Parse reads app["middleware"] into Config (Rust middleware::parse).
|
||||
func Parse(app map[string]any) Config {
|
||||
var cfg Config
|
||||
|
||||
Reference in new issue
Block a user