package
Version:
v1.0.6
Opens a new window with list of versions in this module.
Published: May 28, 2026
License: MIT
Opens a new window with license information.
Imports: 5
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package ginContext 提供从 Gin 上下文中提取请求数据的工具函数,
支持按优先级从 URL 参数、查询参数和请求体中获取指定键的值。
Get 从Gin上下文中获取指定键的值
按照优先级顺序依次从以下位置获取:
1. URL查询参数 (Query)
2. POST表单数据 (PostForm)
3. JSON请求体 (RawData),解析结果会缓存到 context 中避免重复解析
4. URL路径参数 (Param)
参数:
- ctx: Gin上下文对象
- key: 要获取的键名
返回值:
- value: 键对应的值,如果未找到则返回空字符串
Source Files
¶
Click to show internal directories.
Click to hide internal directories.