美文网首页
Grape 写API(待补充)

Grape 写API(待补充)

作者: ifree321 | 来源:发表于2019-09-29 19:58 被阅读0次
    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

    相关文章

      网友评论

          本文标题:Grape 写API(待补充)

          本文链接:https://www.haomeiwen.com/subject/dedauctx.html