12345678910111213141516171819202122232425262728 |
- local skynet = require "skynet"
- -- local httpc = require "http.httpc"
- -- local httpurl = require "http.url"
- -- local dns = require "skynet.dns"
- local httpd = require "http.httpd"
- local sockethelper = require "http.sockethelper"
- local socket = require "skynet.socket"
- local cjson = require "cjson"
- local tools = require "tools"
- local dispatch = function(session, address,id, addr,...)
- socket.start(id)
- local req= tools.read_request(id)
- if req.url == nil or #req.url==0 or req.code~=200 or #req.body==0 then
- skynet.error(req.url)
- skynet.error("错误访问:")
- tools.dump({address=address,id=id,addr=addr,other=...})
- return tools.response(id, req.code, "error!")
- end
- if string.find(req.url, "tg/back/") then
- local func_list = string.split(req.url ,"/")
- skynet.send("backmgr","lua","on_recv",id,func_list[#func_list],req.body)
- return
- end
- end
- skynet.start(function()
- skynet.dispatch("lua", dispatch)
- end)
|