member_gateway_rest/server/server.go

34 lines
800 B
Go
Raw Normal View History

2018-04-06 10:08:38 +00:00
package server
import (
logging "git.loafle.net/commons/logging-go"
crpj "git.loafle.net/commons/rpc-go/protocol/json"
crr "git.loafle.net/commons/rpc-go/registry"
cswf "git.loafle.net/commons/server-go/web/fasthttp"
"git.loafle.net/overflow/member_gateway_rest/service"
"git.loafle.net/overflow/member_gateway_rest/servlet"
)
func NewServer() *cswf.Server {
serverCodec := crpj.NewServerCodec()
rpcRegistry := crr.NewRPCRegistry()
ms := &service.MemberService{}
if err := rpcRegistry.RegisterService(ms, ""); nil != err {
logging.Logger().Error(err)
}
webappS := &servlet.WebappServlet{}
webappS.ServerCodec = serverCodec
webappS.RPCInvoker = rpcRegistry
sh := &ServerHandlers{}
sh.RegisterServlet("/webapp", webappS)
s := &cswf.Server{
ServerHandler: sh,
}
return s
}