response.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. local M = {}
  2. --[[
  3. FUNCTION: 发送响应头
  4. PARAM
  5. state_num : 状态码
  6. state_desc : 状态描述
  7. --]]
  8. function M.send_header(state_num, state_desc)
  9. return fw_response:send_header(state_num, state_desc)
  10. end
  11. --[[
  12. FUNCTION: 发送WebSocket数据
  13. PARAM
  14. data : 数据
  15. opcode : 帧类型(可选,默认文本1;2二进制 8关闭 9ping 10pong)
  16. --]]
  17. function M.send_ws(data, opcode)
  18. return fw_response:send_ws(data, opcode or 1)
  19. end
  20. --[[
  21. FUNCTION: 响应结束
  22. --]]
  23. function M.response_done()
  24. fw_response:response_done()
  25. end
  26. --[[
  27. FUNCTION: 是否已响应
  28. --]]
  29. function M.is_response_done()
  30. return fw_response:is_response_done()
  31. end
  32. --[[
  33. FUNCTION: 发送字符串
  34. PARAM
  35. value : 内容
  36. --]]
  37. function M.send(value)
  38. return fw_response:send(value)
  39. end
  40. --[[
  41. FUNCTION: 发送字符串
  42. PARAM
  43. value : 内容
  44. state_num : 状态码
  45. state_sec : 状态描述
  46. --]]
  47. function M.sendex(value, state_num, state_esc)
  48. return fw_response:sendex(value, state_num, state_esc)
  49. end
  50. --[[
  51. FUNCTION: 发送文件
  52. PARAM
  53. filepath : 文件路径
  54. downbaud : 限速每秒字节(-1=不限速)
  55. state_num : 状态码
  56. state_sec : 状态描述
  57. --]]
  58. function M.send_file(filepath, downbaud, state_num, state_desc)
  59. return fw_response:send_file(filepath, downbaud, state_num, state_desc)
  60. end
  61. --[[
  62. FUNCTION: 重定向请求
  63. PARAM
  64. filepath : 文件路径
  65. MovedPermanently : 是否永久重定向
  66. --]]
  67. function M.redirect(filepath,MovedPermanently)
  68. return fw_response:redirect(filepath,MovedPermanently)
  69. end
  70. --[[
  71. FUNCTION: 转发请求
  72. PARAM
  73. filepath : 转发路径
  74. --]]
  75. function M.forward(filepath)
  76. return fw_response:forward(filepath)
  77. end
  78. --[[
  79. FUNCTION: 设置响应头。
  80. PARAM
  81. name : 名称
  82. value : 值
  83. --]]
  84. function M.header(name, value)
  85. fw_response:header(name, value)
  86. end
  87. --[[
  88. FUNCTION: 置后端渲染。
  89. PARAM
  90. name : 名称
  91. value : 值
  92. --]]
  93. function M.set(name, value)
  94. fw_response:set(name, value)
  95. end
  96. --[[
  97. FUNCTION: 置后端渲染。
  98. PARAM
  99. table : 名称
  100. --]]
  101. function M.sets(tab)
  102. fw_response:sets(tab)
  103. end
  104. return M