惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
S
Secure Thoughts
月光博客
月光博客
美团技术团队
雷峰网
雷峰网
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
W
WeLiveSecurity
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
G
GRAHAM CLULEY
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recent Announcements
Recent Announcements
Webroot Blog
Webroot Blog
T
Tor Project blog
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
罗磊的独立博客
The Register - Security
The Register - Security
Blog — PlanetScale
Blog — PlanetScale
T
Threat Research - Cisco Blogs
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
B
Blog
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Engineering at Meta
Engineering at Meta
Latest news
Latest news
IT之家
IT之家
D
DataBreaches.Net
博客园 - 司徒正美
N
Netflix TechBlog - Medium
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - 代码小伙

gin框架使用zap,在日志中加入trace_id gorm使用gen自动生成模型和查询文件 Go使用base64Captcha生成字母验证码 GoFrame框架查询数据表时对字段取别名 GoFrame框架使用WherePri报错原因 GoFrame框架WebServer默认端口号是什么 GoFrame框架SetFileServerEnabled关闭静态服务不生效 vite修改端口号 用路由方式写一个通用的微信小程序校验文件验证 手机网页通过微信deeplink实现wap支付 position:sticky失效原因分析 mysql把一个表的字段赋值到另一张表 基于jquery的countdown插件实现毫秒倒计时 Vue打包代码如何部署在ThinkPHP项目里 保姆级教程,centos7安装erlang和rabbitmq Element Plus表单resetFields重置表单无效 thinkphp6通过中间件设置跨域 centos7安装jdk vue3中使用swiper6实现轮播
GoFrame框架使用BindHandler设置路由失效的原因
代码小伙 · 2025-08-21 · via 博客园 - 代码小伙

API中

type ThumbsUpReq struct {
	g.Meta    `path:"/thumbsUp" tags:"资讯" method:"post" summary:"给评论点赞/取消点赞"`
	CommentId int `json:"comment_id" v:"required#评论ID不能为空" dc:"评论ID" example:"20"`
}

type ThumbsUpRes struct {
	GoodsNum  int64 `json:"goods_num" dc:"该评论的点赞数量"`
}

router中

s.BindHandler("/cccc", article.NewV1().ThumbsUp)

发现实际注册的路由地址是/thumbsUp而不是/cccc,也就是使用/thumbsUp可以访问,使用/cccc无法访问,是报错的。
查看ghttp包中的ghttp_server_router.go文件,约100-102行,会使用结构体标签中的path覆盖掉s.BindHandler方法注册的路由地址,所以生效的路由实际是/thumbsUp

if v := gmeta.Get(objectReq, gtag.Path); !v.IsEmpty() {
	uri = v.String()
}