2023-06-07 11:47:45 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
2023-06-08 03:03:20 +00:00
|
|
|
config2 "fusenapi/server/data-transfer/internal/config"
|
|
|
|
handler2 "fusenapi/server/data-transfer/internal/handler"
|
|
|
|
svc2 "fusenapi/server/data-transfer/internal/svc"
|
2023-07-11 11:43:46 +00:00
|
|
|
"fusenapi/utils/auth"
|
|
|
|
"net/http"
|
2023-06-07 11:47:45 +00:00
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/conf"
|
|
|
|
"github.com/zeromicro/go-zero/rest"
|
|
|
|
)
|
|
|
|
|
|
|
|
var configFile = flag.String("f", "etc/data-transfer.yaml", "the config file")
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
2023-06-08 03:03:20 +00:00
|
|
|
var c config2.Config
|
2023-06-07 11:47:45 +00:00
|
|
|
conf.MustLoad(*configFile, &c)
|
|
|
|
|
2023-07-11 11:43:46 +00:00
|
|
|
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
|
|
|
|
|
|
|
}))
|
2023-06-07 11:47:45 +00:00
|
|
|
defer server.Stop()
|
|
|
|
|
2023-06-08 03:03:20 +00:00
|
|
|
ctx := svc2.NewServiceContext(c)
|
|
|
|
handler2.RegisterHandlers(server, ctx)
|
2023-06-07 11:47:45 +00:00
|
|
|
|
|
|
|
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
|
|
|
server.Start()
|
|
|
|
}
|