简体   繁体   English

在水牛城里反向路由

[英]Reverse routing in buffalo

Is there any possibility to use a reverse router, eg similiar to the Play framework? 是否有可能使用反向路由器,例如类似于Play框架的路由器? This would be helpful in order not to hardcode URLs outside the app.go. 为了避免在app.go之外对URL进行硬编码,这将很有帮助。

In app.go use Name() to define a name for the route (as in mux). 在app.go中,使用Name()定义路线的名称(如mux)。 For example: 例如:

auth.GET("/{provider}", bah).Name("login")

buffalo will however append "Path" to it and make it available as 但是,buffalo会在其后附加“路径”,并以

loginPath({key : value})

for example: 例如:

<a href="<%= loginPath({provider: "github"}) %>">login</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM