2
有没有哪个 golang web 框架支持谷歌 api 这个规范的 (https://xxx.com/v1/api:method...
source link: https://www.v2ex.com/t/812454
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
有没有哪个 golang web 框架支持谷歌 api 这个规范的 (https://xxx.com/v1/api:method)
第 1 条附言 · 15 小时 58 分钟前
标题只是个例子... 我不知道这个域名是 porn 相关的
第 2 条附言 · 15 小时 28 分钟前
目前如同 #5 老哥所说, https://github.com/gorilla/mux 确实可以实现, 但是还是希望能找到一个类似 https://github.com/gin-gonic/gin 的 web 框架, 路由更加自由
gin 的 issue 也有人吐槽过这个...
gin 的 issue 也有人吐槽过这个...
11 条回复 • 2021-11-02 21:00:55 +08:00
XTTX 15 小时 36 分钟前
看得不是很懂。 推荐错了就当我没有说过。gorilla mux
r := mux.NewRouter()
s := r.PathPrefix("/1").Subrouter()
s.HandleFunc("/{api:[a-z]+}", ProductsHandler)
ProductsHandler 里 通过 vars := web.Params(r)
apiMethod:= vars["api"] 读出来
r := mux.NewRouter()
s := r.PathPrefix("/1").Subrouter()
s.HandleFunc("/{api:[a-z]+}", ProductsHandler)
ProductsHandler 里 通过 vars := web.Params(r)
apiMethod:= vars["api"] 读出来
JoeBreeze 15 小时 30 分钟前
@XTTX #5 多谢老哥, 这个确实有在公司的项目里看到过, 而个人用的是 gin, gin 自带的路由是不能使用 :method, 会被 gin.Context 当作一个参数 "method", 所以想找个类似 gin 这种好用的框架, 但是路由可以更加自由一些
XTTX 14 小时 7 分钟前
@JoeBreeze 既然都是 custom method 了, 就当作 regex 读吧。 我还不是很懂你的需求,不过 go 的好处就是可以自己随意封装。 可以参考一下 ardanlabs service 把 treeMux 封装成了自己需要的样子,所有的 web 框架都放在 foundation 里,app 文件夹里的 handler 调用
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK