probe_gateway_rpc/server/server.go

35 lines
730 B
Go
Raw Normal View History

2018-04-12 12:07:02 +00:00
package server
import (
2018-05-08 11:12:08 +00:00
crpj "git.loafle.net/commons/rpc-go/protocol/json"
2018-04-12 12:07:02 +00:00
cssw "git.loafle.net/commons/server-go/socket/web"
2018-04-26 08:17:12 +00:00
"git.loafle.net/overflow/probe_gateway_rpc/config"
2018-04-12 12:07:02 +00:00
"git.loafle.net/overflow/probe_gateway_rpc/servlet"
)
func New(_config *config.Config) *cssw.Server {
2018-05-08 11:12:08 +00:00
rpcServerCodec := crpj.NewServerCodec()
2018-04-12 12:07:02 +00:00
as := &servlet.AuthServlets{}
2018-05-08 11:12:08 +00:00
as.RPCServerCodec = rpcServerCodec
2018-04-13 12:17:58 +00:00
as.UseSession = true
2018-05-08 11:12:08 +00:00
2018-04-12 12:07:02 +00:00
ps := &servlet.ProbeServlets{}
2018-05-08 11:12:08 +00:00
ps.RPCServerCodec = rpcServerCodec
2018-04-13 12:17:58 +00:00
ps.UseSession = true
2018-05-08 11:12:08 +00:00
2018-04-12 12:07:02 +00:00
sh := &ServerHandlers{
ServerHandlers: *_config.ServerHandler,
2018-04-12 12:39:48 +00:00
Config: _config,
2018-04-12 12:07:02 +00:00
}
sh.RegisterServlet("/auth", as)
sh.RegisterServlet("/probe", ps)
s := &cssw.Server{
ServerHandler: sh,
}
return s
}