跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

agent_routes.go

27 行 · 801 B历史下载
1package workbench
2
3import (
4 "net/http"
5 "sort"
6)
7
8// Keep route discovery attached to the actual registrations. Adding a UI API
9// automatically makes it visible to an external agent on that same listener.
10type routeRegistrar interface {
11 HandleFunc(string, func(http.ResponseWriter, *http.Request))
12}
13type discoverableMux struct {
14 *http.ServeMux
15 patterns []string
16}
17
18func newDiscoverableMux() *discoverableMux { return &discoverableMux{ServeMux: http.NewServeMux()} }
19func (m *discoverableMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) {
20 m.patterns = append(m.patterns, pattern)
21 m.ServeMux.HandleFunc(pattern, handler)
22}
23func (m *discoverableMux) routes() []string {
24 patterns := append([]string(nil), m.patterns...)
25 sort.Strings(patterns)
26 return patterns
27}