iris

package
v0.0.0-...-ff5ac03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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

type HandlerFunc func(ctx iris.Context) (types.Panel, error)

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

func (is *Iris) AddHandler(method, path string, handlers context.Handlers)

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

func (is *Iris) FormParam() url.Values

FormParam 实现了 Adapter.FormParam 方法 该方法用于获取表单参数 表单参数通常来自 POST 请求的请求体 Iris 的 FormValues() 方法会自动解析表单数据 返回值:

  • url.Values: 表单参数的键值对集合

func (*Iris) GetCookie

func (is *Iris) GetCookie() (string, error)

GetCookie 实现了 Adapter.GetCookie 方法 该方法用于获取指定名称的 Cookie 值 Cookie 用于存储用户会话信息,如登录凭证 返回值:

  • string: Cookie 的值
  • error: 获取 Cookie 时的错误(Iris 的 GetCookie 方法不返回错误)

func (*Iris) IsPjax

func (is *Iris) IsPjax() bool

IsPjax 实现了 Adapter.IsPjax 方法 该方法用于判断当前请求是否为 PJAX 请求 PJAX (PushState + AJAX) 是一种技术,允许在不刷新整个页面的情况下更新页面内容 GoAdmin 使用 PJAX 来提供更流畅的用户体验 返回值:

  • bool: 如果是 PJAX 请求返回 true,否则返回 false

func (*Iris) Lang

func (is *Iris) Lang() string

Lang 实现了 Adapter.Lang 方法 该方法用于从查询参数中获取语言设置 GoAdmin 支持多语言,语言通过 URL 查询参数 __ga_lang 指定 返回值:

  • string: 语言代码,如 "zh-CN"、"en-US" 等

func (*Iris) Method

func (is *Iris) Method() string

Method 实现了 Adapter.Method 方法 该方法用于获取当前请求的 HTTP 方法 返回值:

  • string: HTTP 方法,如 "GET"、"POST"、"PUT"、"DELETE" 等

func (*Iris) Name

func (*Iris) Name() string

Name 实现了 Adapter.Name 方法 返回适配器的名称,用于标识不同的框架适配器 返回值:

  • string: 适配器名称 "iris"

func (*Iris) Path

func (is *Iris) Path() string

Path 实现了 Adapter.Path 方法 该方法用于获取当前请求的路径 返回值:

  • string: 请求路径,如 "/admin/info"

func (*Iris) Query

func (is *Iris) Query() url.Values

Query 实现了 Adapter.Query 方法 该方法用于获取 URL 查询参数 查询参数是 URL 中 ? 后面的键值对 返回值:

  • url.Values: 查询参数的键值对集合

func (*Iris) Redirect

func (is *Iris) Redirect()

Redirect 实现了 Adapter.Redirect 方法 该方法用于重定向到登录页面 当用户未登录或会话过期时,GoAdmin 会调用此方法将用户重定向到登录页面 使用 http.StatusFound (302) 状态码进行临时重定向

func (*Iris) Request

func (is *Iris) Request() *http.Request

Request 实现了 Adapter.Request 方法 该方法用于获取原始的 HTTP 请求对象 返回值:

  • *http.Request: 标准 HTTP 请求对象指针

func (*Iris) SetApp

func (is *Iris) SetApp(app interface{}) error

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

func (is *Iris) Use(app interface{}, plugs []plugins.Plugin) error

Use 实现了 Adapter.Use 方法 该方法用于初始化并使用 GoAdmin 插件 参数:

  • app: Web 应用实例,实际类型为 *iris.Application
  • plugs: 插件列表,包含要加载的 GoAdmin 插件

返回值:

  • error: 初始化过程中的错误,成功则为 nil

func (*Iris) User

func (is *Iris) User(ctx interface{}) (models.UserModel, bool)

User 实现了 Adapter.User 方法 该方法从请求上下文中获取当前登录的用户信息 参数:

  • ctx: 请求上下文接口,实际类型为 iris.Context

返回值:

  • models.UserModel: 用户模型,包含用户信息
  • bool: 是否成功获取用户信息

func (*Iris) Write

func (is *Iris) Write(body []byte)

Write 实现了 Adapter.Write 方法 该方法用于写入响应体 参数:

  • body: 要写入的响应体字节数组

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL