member_gateway_rest/server/server.go

40 lines
950 B
Go
Raw Normal View History

2018-04-06 10:08:38 +00:00
package server
import (
2018-04-10 06:58:38 +00:00
cdr "git.loafle.net/commons/di-go/registry"
"git.loafle.net/commons/logging-go"
2018-04-06 10:08:38 +00:00
cswf "git.loafle.net/commons/server-go/web/fasthttp"
2018-04-10 06:58:38 +00:00
oca "git.loafle.net/overflow/commons-go/annotation"
"git.loafle.net/overflow/member_gateway_rest/config"
2018-04-06 10:08:38 +00:00
"git.loafle.net/overflow/member_gateway_rest/servlet"
)
2018-04-10 06:58:38 +00:00
func NewServer(_config *config.Config) *cswf.Server {
2018-04-06 10:08:38 +00:00
2018-04-11 13:08:41 +00:00
cdr.RegisterResource("VerifyKey", _config.VerifyKey)
cdr.RegisterResource("SignKey", _config.SignKey)
2018-04-10 14:30:45 +00:00
services, err := cdr.GetInstancesByAnnotationType(oca.RESTServiceAnnotationType)
2018-04-10 06:58:38 +00:00
if nil != err {
logging.Logger().Panic(err)
}
2018-04-06 12:17:07 +00:00
webappS := &servlet.WebappServlets{}
2018-04-10 14:30:45 +00:00
if err := webappS.RegisterRESTServices(services); nil != err {
logging.Logger().Panic(err)
}
2018-04-06 10:08:38 +00:00
2018-04-10 06:58:38 +00:00
sh := &ServerHandlers{
ServerHandlers: *_config.ServerHandler,
Config: _config,
}
2018-04-06 10:08:38 +00:00
sh.RegisterServlet("/webapp", webappS)
s := &cswf.Server{
ServerHandler: sh,
}
return s
}