36 lines
741 B
Go
36 lines
741 B
Go
package logic
|
|
|
|
import (
|
|
"fmt"
|
|
"fusenapi/server/webset/internal/config"
|
|
"fusenapi/server/webset/internal/handler"
|
|
"fusenapi/server/webset/internal/svc"
|
|
"log"
|
|
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
"github.com/zeromicro/go-zero/rest"
|
|
)
|
|
|
|
var testConfigFile = "../etc/wetset.yaml"
|
|
var cnf config.Config
|
|
var gserver *rest.Server
|
|
|
|
func init() {
|
|
log.SetFlags(log.Llongfile)
|
|
gserver = GetTestServer(testConfigFile)
|
|
}
|
|
|
|
func GetTestServer(testConfigFile string) *rest.Server {
|
|
|
|
conf.MustLoad(testConfigFile, &cnf)
|
|
|
|
server := rest.MustNewServer(cnf.RestConf)
|
|
defer server.Stop()
|
|
|
|
ctx := svc.NewServiceContext(cnf)
|
|
handler.RegisterHandlers(server, ctx)
|
|
|
|
fmt.Printf("Starting server at %s:%d...\n", cnf.Host, cnf.Port)
|
|
return server
|
|
}
|