member_gateway_rest/server/server.go
crusader 1dfb55b4ba ing
2018-04-12 19:08:01 +09:00

40 lines
957 B
Go

package server
import (
cdr "git.loafle.net/commons/di-go/registry"
"git.loafle.net/commons/logging-go"
cswf "git.loafle.net/commons/server-go/web/fasthttp"
occa "git.loafle.net/overflow/commons-go/core/annotation"
"git.loafle.net/overflow/member_gateway_rest/config"
"git.loafle.net/overflow/member_gateway_rest/servlet"
)
func NewServer(_config *config.Config) *cswf.Server {
cdr.RegisterResource("VerifyKey", _config.VerifyKey)
cdr.RegisterResource("SignKey", _config.SignKey)
services, err := cdr.GetInstancesByAnnotationType(occa.RESTServiceAnnotationType)
if nil != err {
logging.Logger().Panic(err)
}
webappS := &servlet.WebappServlets{}
if err := webappS.RegisterRESTServices(services); nil != err {
logging.Logger().Panic(err)
}
sh := &ServerHandlers{
ServerHandlers: *_config.ServerHandler,
Config: _config,
}
sh.RegisterServlet("/webapp", webappS)
s := &cswf.Server{
ServerHandler: sh,
}
return s
}