Go Iris 路由

栏目: Go · 发布时间: 6年前

内容简介:直接通过 function 绑定 controller,function name 映射到 路由的地址function named rule:通过控制器方法的输入参数访问动态路径参数,不需要绑定。当您使用Iris的默认语法来解析来自控制器的处理程序时,您需要使用By字来为方法添加后缀,大写是一个新的子路径。例: 如这种形式 mvc.New(app.Party(“/user”)).Handle(new(user.Controller)) 则:

路由配置规则

直接通过 function 绑定 controller,function name 映射到 路由的地址

function named rule:

func(*Controller) GetLoginBy(id int64)
绑定的controller HTTP-method+routePath
map to - GET:/user/login/{param:long}

通过控制器方法的输入参数访问动态路径参数,不需要绑定。当您使用Iris的默认语法来解析来自控制器的处理程序时,您需要使用By字来为方法添加后缀,大写是一个新的子路径。例: 如这种形式 mvc.New(app.Party(“/user”)).Handle(new(user.Controller)) 则:

  • func(*Controller) Get() – GET:/user.
  • func(*Controller) Post() – POST:/user.
  • func(*Controller) GetLogin() – GET:/user/login
  • func(*Controller) PostLogin() – POST:/user/login
  • func(*Controller) GetProfileFollowers() – GET:/user/profile/followers
  • func(*Controller) PostProfileFollowers() – POST:/user/profile/followers
  • func(*Controller) GetBy(id int64) – GET:/user/{param:long}
  • func(*Controller) PostBy(id int64) – POST:/user/{param:long}

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

How to Design Programs

How to Design Programs

Matthias Felleisen、Robert Bruce Findler、Matthew Flatt、Shriram Krishnamurthi / The MIT Press / 2001-2-12 / 71.00美元

This introduction to programming places computer science in the core of a liberal arts education. Unlike other introductory books, it focuses on the program design process. This approach fosters a var......一起来看看 《How to Design Programs》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具