Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Main = gcmd.Command{ Name: "main", Usage: "main", Brief: "start http server", Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) go func() { sig := <-sigChan g.Log().Infof(ctx, "收到关闭信号: %v,开始优雅关闭...", sig) g.Log().Info(ctx, "正在刷盘缓存数据...") if messageCache := internalCache.GetMessageCache(); messageCache != nil { messageCache.Close() g.Log().Info(ctx, "✓ 消息缓存层已关闭") } if mcpLogCache := internalCache.GetMCPCallLogCache(); mcpLogCache != nil { mcpLogCache.Close() g.Log().Info(ctx, "✓ MCP日志缓存层已关闭") } g.Log().Info(ctx, "✓ 所有缓存数据已刷盘完成") if err := g.Server().Shutdown(); err != nil { g.Log().Errorf(ctx, "HTTP服务器关闭失败: %v", err) } os.Exit(0) }() s := g.Server() s.SetServerRoot(".") s.AddStaticPath("/", ".") s.Group("/api", func(group *ghttp.RouterGroup) { group.Middleware(MiddlewareMultipartMaxMemory, MiddlewareHandlerResponse, ghttp.MiddlewareCORS) group.Bind( kbgo.NewV1(), ) }) s.Run() return nil }, } )
Functions ¶
func MiddlewareHandlerResponse ¶
MiddlewareHandlerResponse is the default middleware handling handler response object and its error.
func MiddlewareMultipartMaxMemory ¶
MiddlewareMultipartMaxMemory 根据不同的路由设置不同的文件上传大小限制
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.