Documentation
¶
Index ¶
- func Content(handler HandlerFunc) iris.Handler
- type HandlerFunc
- type Iris
- func (is *Iris) AddHandler(method, path string, handlers context.Handlers)
- func (is *Iris) Content(ctx interface{}, getPanelFn types.GetPanelFn, fn context.NodeProcessor, ...)
- func (is *Iris) FormParam() url.Values
- func (is *Iris) GetCookie() (string, error)
- func (is *Iris) IsPjax() bool
- func (is *Iris) Lang() string
- func (is *Iris) Method() string
- func (*Iris) Name() string
- func (is *Iris) Path() string
- func (is *Iris) Query() url.Values
- func (is *Iris) Redirect()
- func (is *Iris) Request() *http.Request
- func (is *Iris) SetApp(app interface{}) error
- func (is *Iris) SetContentType()
- func (*Iris) SetContext(contextInterface interface{}) adapter.WebFrameWork
- func (is *Iris) Use(app interface{}, plugs []plugins.Plugin) error
- func (is *Iris) User(ctx interface{}) (models.UserModel, bool)
- func (is *Iris) Write(body []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Content ¶
func Content(handler HandlerFunc) iris.Handler
Content 是一个辅助函数,用于创建 Iris 处理器函数 该处理器将 Iris 的请求处理与 GoAdmin 的内容渲染集成 参数:
- handler: 处理器函数,用于生成管理面板
返回值:
- iris.Handler: Iris 处理器函数类型
Types ¶
type HandlerFunc ¶
HandlerFunc 定义了 Iris 框架的处理器函数类型 它接收 Iris 上下文并返回面板和可能的错误 参数:
- ctx: Iris 请求上下文
返回值:
- types.Panel: 管理面板
- error: 处理过程中的错误
type Iris ¶
type Iris struct {
adapter.BaseAdapter
// contains filtered or unexported fields
}
Iris 结构体实现了 GoAdmin 的适配器接口 它作为 Iris 框架和 GoAdmin 管理后台之间的桥梁 嵌入了 adapter.BaseAdapter 以获得基础适配器功能 ctx 字段存储当前的 Iris 请求上下文 app 字段存储 Iris 应用实例
func (*Iris) AddHandler ¶
AddHandler 实现了 Adapter.AddHandler 方法 该方法用于向 Iris 应用添加路由处理器 Iris 的路由参数已经解析在上下文中,需要转换为标准 URL 查询参数格式 ?param=value 参数:
- method: HTTP 方法,如 "GET"、"POST" 等
- path: 路由路径,如 "/admin" 等
- handlers: 处理器链,包含要执行的中间件和处理器
func (*Iris) Content ¶
func (is *Iris) Content(ctx interface{}, getPanelFn types.GetPanelFn, fn context.NodeProcessor, btns ...types.Button)
Content 实现了 Adapter.Content 方法 该方法用于渲染管理面板内容 参数:
- ctx: 请求上下文接口
- getPanelFn: 获取面板的函数,用于生成管理面板
- fn: 节点处理器,用于处理面板中的节点
- btns: 按钮列表,用于面板上的操作按钮
func (*Iris) FormParam ¶
FormParam 实现了 Adapter.FormParam 方法 该方法用于获取表单参数 表单参数通常来自 POST 请求的请求体 Iris 的 FormValues() 方法会自动解析表单数据 返回值:
- url.Values: 表单参数的键值对集合
func (*Iris) GetCookie ¶
GetCookie 实现了 Adapter.GetCookie 方法 该方法用于获取指定名称的 Cookie 值 Cookie 用于存储用户会话信息,如登录凭证 返回值:
- string: Cookie 的值
- error: 获取 Cookie 时的错误(Iris 的 GetCookie 方法不返回错误)
func (*Iris) IsPjax ¶
IsPjax 实现了 Adapter.IsPjax 方法 该方法用于判断当前请求是否为 PJAX 请求 PJAX (PushState + AJAX) 是一种技术,允许在不刷新整个页面的情况下更新页面内容 GoAdmin 使用 PJAX 来提供更流畅的用户体验 返回值:
- bool: 如果是 PJAX 请求返回 true,否则返回 false
func (*Iris) Lang ¶
Lang 实现了 Adapter.Lang 方法 该方法用于从查询参数中获取语言设置 GoAdmin 支持多语言,语言通过 URL 查询参数 __ga_lang 指定 返回值:
- string: 语言代码,如 "zh-CN"、"en-US" 等
func (*Iris) Method ¶
Method 实现了 Adapter.Method 方法 该方法用于获取当前请求的 HTTP 方法 返回值:
- string: HTTP 方法,如 "GET"、"POST"、"PUT"、"DELETE" 等
func (*Iris) Query ¶
Query 实现了 Adapter.Query 方法 该方法用于获取 URL 查询参数 查询参数是 URL 中 ? 后面的键值对 返回值:
- url.Values: 查询参数的键值对集合
func (*Iris) Redirect ¶
func (is *Iris) Redirect()
Redirect 实现了 Adapter.Redirect 方法 该方法用于重定向到登录页面 当用户未登录或会话过期时,GoAdmin 会调用此方法将用户重定向到登录页面 使用 http.StatusFound (302) 状态码进行临时重定向
func (*Iris) Request ¶
Request 实现了 Adapter.Request 方法 该方法用于获取原始的 HTTP 请求对象 返回值:
- *http.Request: 标准 HTTP 请求对象指针
func (*Iris) SetApp ¶
SetApp 实现了 Adapter.SetApp 方法 该方法用于设置 Iris 应用实例到适配器中 参数:
- app: Web 应用实例,实际类型应为 *iris.Application
返回值:
- error: 如果参数类型错误则返回错误,成功则为 nil
func (*Iris) SetContentType ¶
func (is *Iris) SetContentType()
SetContentType 实现了 Adapter.SetContentType 方法 该方法用于设置响应的内容类型 GoAdmin 默认使用 HTML 内容类型,确保浏览器正确渲染页面
func (*Iris) SetContext ¶
func (*Iris) SetContext(contextInterface interface{}) adapter.WebFrameWork
SetContext 实现了 Adapter.SetContext 方法 该方法用于设置当前请求的上下文到适配器中 参数:
- contextInterface: 请求上下文接口,实际类型应为 iris.Context
返回值:
- adapter.WebFrameWork: 返回新的适配器实例,包含设置的上下文
func (*Iris) Use ¶
Use 实现了 Adapter.Use 方法 该方法用于初始化并使用 GoAdmin 插件 参数:
- app: Web 应用实例,实际类型为 *iris.Application
- plugs: 插件列表,包含要加载的 GoAdmin 插件
返回值:
- error: 初始化过程中的错误,成功则为 nil