• lapis 处理接收到的json 数据


     备注:
         在restful api 开发过程中,大家一般使用的都是json 格式的数据lapis 
         在处理json 数据上也是比较方便的
     
    1. 使用的api 说明
    local json_params = require("lapis.application").json_params     
    2. 参考代码
    // app.lua 
    app:match("/json", json_params(function(self)
      -- 只处理name 属性
      local valueinfo = {name = self.params.name}
      -- 原样返回
      local  jsondata =self.params
      return {json = valeinfo};
      -- return {json = jsondata}
    end))
    
    实际上具体的原理就是判断content_type 如果为application/json 调用nginx lua 的ngx.req.read_body() 方法
    3. 参考文档
    http://leafo.net/lapis/reference/utilities.html
  • 相关阅读:
    Eighth scrum meeting
    Seventh scrum meeting
    Sixth scrum meeting
    Fifth scrum meeting
    Forth scrum meeting
    Third scrum meeting
    2019-07-25 L430 生物 GPS
    L429 Why Do Smart People Do Foolish Things?
    L427 长难句
    L426
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/7856260.html
Copyright © 2020-2023  润新知