2023-06-16 02:58:43 +00:00
|
|
|
package logic
|
2023-06-12 11:52:11 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fusenapi/server/home-user-auth/internal/config"
|
|
|
|
"fusenapi/server/home-user-auth/internal/handler"
|
|
|
|
"fusenapi/server/home-user-auth/internal/svc"
|
2023-06-19 02:33:51 +00:00
|
|
|
"log"
|
2023-06-12 11:52:11 +00:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
|
|
"github.com/zeromicro/go-zero/rest"
|
|
|
|
)
|
|
|
|
|
2023-06-15 09:51:06 +00:00
|
|
|
var testConfigFile = "../etc/home-user-auth.yaml"
|
2023-06-12 11:52:11 +00:00
|
|
|
var cnf config.Config
|
|
|
|
var gserver *rest.Server
|
|
|
|
|
|
|
|
func init() {
|
2023-06-19 02:33:51 +00:00
|
|
|
log.SetFlags(log.Llongfile)
|
2023-06-25 05:15:55 +00:00
|
|
|
gserver = GetTestServer()
|
2023-06-12 11:52:11 +00:00
|
|
|
}
|
|
|
|
|
2023-06-25 05:15:55 +00:00
|
|
|
func GetTestServer() *rest.Server {
|
2023-06-12 11:52:11 +00:00
|
|
|
|
2023-06-15 09:51:06 +00:00
|
|
|
conf.MustLoad(testConfigFile, &cnf)
|
2023-06-12 11:52:11 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|