Documentation
¶
Index ¶
- func GetContextValue(ctx context.Context, key string) (interface{}, bool)
- type APIDefinition
- type APIFramework
- func (f *APIFramework) AddWeaverService(s interface{}) error
- func (f *APIFramework) EnableDebug() *APIFramework
- func (f *APIFramework) GenerateSwaggerJSON() (string, error)
- func (f *APIFramework) GetController(name string) (interface{}, bool)
- func (f *APIFramework) GetServer() http.Handler
- func (f *APIFramework) GetWeaverService(name string) (interface{}, error)
- func (f *APIFramework) Init()
- func (f *APIFramework) MustGetWeaverService(name string, target interface{}) error
- func (f *APIFramework) NewStaticHandler(fs fs.FS, dir string) *StaticHandler
- func (f *APIFramework) PrintAPIRoutes()
- func (f *APIFramework) RegisterController(prefix string, controllers ...interface{}) error
- func (f *APIFramework) SetContextValue(key string, value interface{})
- func (f *APIFramework) SetFileSystem(fs fs.FS) *APIFramework
- func (f *APIFramework) SetStaticDir(dir string) *APIFramework
- func (f *APIFramework) SetWebRoot(dir string) *APIFramework
- func (f *APIFramework) WithMiddleware(middlewares ...mux.MiddlewareFunc) *APIFramework
- type Controller
- type StaticHandler
- type WeaverContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIDefinition ¶
type APIDefinition struct {
HandlerName string
RequestType reflect.Type
ResponseType reflect.Type
Meta meta.Meta
}
APIDefinition 定义API结构
type APIFramework ¶
type APIFramework struct {
// contains filtered or unexported fields
}
APIFramework 核心框架结构
func (*APIFramework) AddWeaverService ¶
func (f *APIFramework) AddWeaverService(s interface{}) error
AddWeaverService 自动添加 ServiceWeaver 服务
func (*APIFramework) EnableDebug ¶
func (f *APIFramework) EnableDebug() *APIFramework
EnableDebug 启用调试模式
func (*APIFramework) GenerateSwaggerJSON ¶
func (f *APIFramework) GenerateSwaggerJSON() (string, error)
GenerateSwaggerJSON 生成完整的 Swagger JSON
func (*APIFramework) GetController ¶
func (f *APIFramework) GetController(name string) (interface{}, bool)
GetController 获取已注册的控制器
func (*APIFramework) GetServer ¶
func (f *APIFramework) GetServer() http.Handler
GetServer 返回http.Handler接口,用于启动服务
func (*APIFramework) GetWeaverService ¶
func (f *APIFramework) GetWeaverService(name string) (interface{}, error)
GetWeaverService 获取 ServiceWeaver 服务的通用方法
func (*APIFramework) MustGetWeaverService ¶
func (f *APIFramework) MustGetWeaverService(name string, target interface{}) error
MustGetWeaverService 获取 ServiceWeaver 服务并进行类型断言
func (*APIFramework) NewStaticHandler ¶
func (f *APIFramework) NewStaticHandler(fs fs.FS, dir string) *StaticHandler
NewStaticHandler 创建静态文件处理器
func (*APIFramework) PrintAPIRoutes ¶
func (f *APIFramework) PrintAPIRoutes()
PrintAPIRoutes 输出所有注册的API访问地址
func (*APIFramework) RegisterController ¶
func (f *APIFramework) RegisterController(prefix string, controllers ...interface{}) error
RegisterController 注册控制器
func (*APIFramework) SetContextValue ¶
func (f *APIFramework) SetContextValue(key string, value interface{})
SetContextValue 设置全局上下文值
func (*APIFramework) SetFileSystem ¶
func (f *APIFramework) SetFileSystem(fs fs.FS) *APIFramework
SetFileSystem 设置文件系统
func (*APIFramework) SetStaticDir ¶
func (f *APIFramework) SetStaticDir(dir string) *APIFramework
SetStaticDir 设置静态资源目录
func (*APIFramework) SetWebRoot ¶
func (f *APIFramework) SetWebRoot(dir string) *APIFramework
SetWebRoot 设置Web根目录
func (*APIFramework) WithMiddleware ¶
func (f *APIFramework) WithMiddleware(middlewares ...mux.MiddlewareFunc) *APIFramework
WithMiddleware 添加一个或多个中间件
type StaticHandler ¶
StaticHandler 处理静态文件的结构
func (*StaticHandler) ServeHTTP ¶
func (sh *StaticHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP 实现 http.Handler 接口
type WeaverContext ¶
type WeaverContext struct {
Services map[string]interface{} // 存储任意 ServiceWeaver 服务,包括配置
}
WeaverContext 包含 ServiceWeaver 相关的上下文
Click to show internal directories.
Click to hide internal directories.