gpt4 book ai didi

web-services - Gin 通配符路由与现有子项冲突

转载 作者:IT王子 更新时间:2023-10-29 01:56:44 25 4
gpt4 key购买 nike

<分区>

我想构建一个 gin服务于以下路线的程序:

r.GET("/special", ... // Serves a special resource.
r.Any("/*", ... // Serves a default resource.

但是,这样的程序会在运行时出现 panic:

[GIN-debug] GET    /special                  --> main.main.func1 (2 handlers)
[GIN-debug] GET /* --> main.main.func2 (2 handlers)
panic: wildcard route '*' conflicts with existing children in path '/*'

是否可以创建一个 gin 程序,为每个路由提供默认资源除了为服务不同资源的单个路由提供服务?

网络上的许多页面让我相信使用默认的 gin 路由器是不可能的,那么从 gin 程序提供这些路由的最简单方法是什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com