| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- local session = require("fastweb.session")
- local M = {}
- --[[
- FUNCTION: 取协议头
- PARAM
- name : 名称
- --]]
- function M.header(name)
- return fw_request:header(name)
- end
- --[[
- FUNCTION: 取协议头(表)
- PARAM
- name : 名称
- --]]
- function M.headers()
- return fw_request:headers()
- end
- --[[
- FUNCTION: 取请求类型
- RETURN
- 请求类型:GET, POST, PUT, DEL, HEAD 等
- --]]
- function M.method()
- return fw_request:method()
- end
- --[[
- FUNCTION: 取请求路径
- --]]
- function M.filepath()
- return fw_request:filepath()
- end
- --[[
- FUNCTION: 取请求主机
- --]]
- function M.host()
- return fw_request:host()
- end
- --[[
- FUNCTION: 取请求参数
- DESC:支持BODY、URL和JSON一级属性的获取。
- PARAM
- name : 参数名
- throw : 为空时是否抛出异常
- --]]
- function M.param(name,throw)
- return fw_request:param(name,throw)
- end
- --[[
- FUNCTION: 取请求发起IP地址
- --]]
- function M.remote_ipaddress()
- return fw_request:remote_ipaddress()
- end
- --[[
- FUNCTION: 取请求发起端口
- --]]
- function M.remote_port()
- return fw_request:remote_port()
- end
- --[[
- FUNCTION: 取会话session
- PARAM
- session_id : 此ID自行维护唯一
- --]]
- function M.session(session_id)
- return session.new(fw_request:session(session_id))
- end
- --[[
- FUNCTION: 获取请求体参数表
- --]]
- function M.body_param()
- return fw_request:body_param()
- end
- --[[
- FUNCTION: 获取URL参数表
- --]]
- function M.url_param()
- return fw_request:url_param()
- end
- --[[
- FUNCTION: 获取请求体字符串
- --]]
- function M.body()
- return fw_request:body()
- end
- --[[
- FUNCTION: 获取表单信息
- --]]
- function M.multipart()
- return fw_request:multipart()
- end
- --[[
- FUNCTION: 读取表单数据
- --]]
- function M.multipart_content(id)
- return fw_request:multipart_content(id)
- end
- --[[
- FUNCTION: 保存表单数据
- --]]
- function M.multipart_content_save(id,filepath)
- return fw_request:multipart_content_save(id,filepath)
- end
- --[[
- FUNCTION: 读取表单数据
- --]]
- function M.multipart_content_name(name)
- -- 按name字段查找对应的表单条目,取其id,然后调用multipart_content
- local multipart_list = M.multipart()
- for _, item in ipairs(multipart_list or {}) do
- if item.param and item.param.name == name then
- return M.multipart_content(item.id)
- end
- end
- return nil
- end
- --[[
- FUNCTION: 置临时数据(仅本次请求有效)
- --]]
- function M.set(name,value)
- fw_request:set(name,value)
- end
- --[[
- FUNCTION: 取临时数据(仅本次请求有效)
- --]]
- function M.get(name)
- return fw_request:get(name)
- end
- --[[
- FUNCTION: 取临时数据(仅本次请求有效)
- --]]
- function M.gets()
- return fw_request:gets()
- end
- --[[
- FUNCTION: 保存请求体到文件
- --]]
- function M.save_body(filepath)
- return fw_request:save_body(filepath)
- end
- return M
|