package main

import (
	"context"
	"flag"
	"fmt"

	"haixun-backend/internal/config"
	"haixun-backend/internal/handler"
	"haixun-backend/internal/svc"

	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/rest"
)

var configFile = flag.String("f", "etc/gateway.yaml", "config file")

func main() {
	flag.Parse()

	var c config.Config
	conf.MustLoad(*configFile, &c)

	server := rest.MustNewServer(c.RestConf)
	defer server.Stop()

	sc := svc.NewServiceContext(c)
	defer sc.Close(context.Background())

	handler.RegisterHandlers(server, sc)

	fmt.Printf("Starting backend backend at %s:%d...\n", c.Host, c.Port)
	server.Start()
}
