ginContext

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ginContext 提供从 Gin 上下文中提取请求数据的工具函数, 支持按优先级从 URL 参数、查询参数和请求体中获取指定键的值。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx *gin.Context, key string) (value string)

Get 从Gin上下文中获取指定键的值 按照优先级顺序依次从以下位置获取: 1. URL查询参数 (Query) 2. POST表单数据 (PostForm) 3. JSON请求体 (RawData),解析结果会缓存到 context 中避免重复解析 4. URL路径参数 (Param)

参数:

  • ctx: Gin上下文对象
  • key: 要获取的键名

返回值:

  • value: 键对应的值,如果未找到则返回空字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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