Grape 写API(待补充)

2019-09-29  本文已影响0人  ifree321
  1. helper 文件的组织管理和使用

https://til.codes/using-helper-methods-and-helper-modules-in-rails-grape-to-keep-the-code-dry/

  1. Entity 的使用

2.1 present 放在hash内返回

# 返回 格式
{
  status: 1,
  objects: [{id:12, name: xxx}, {id: 13, name :xxxx}]
}

写法

        present :status, 1
        present :objects, objects, with: ObjectEntity::Index

参考:

https://ruby-china.org/topics/28999

https://ruby-china.org/topics/24697

https://ruby-china.org/topics/22426

上一篇 下一篇

猜你喜欢

热点阅读