fusenapi/server/shopping-cart-confirmation/shopping-cart-confirmation.go

56 lines
1.3 KiB
Go
Raw Normal View History

2023-06-13 04:15:06 +00:00
package main
import (
"flag"
"fmt"
2023-07-11 11:43:46 +00:00
"net/http"
2023-07-12 02:22:03 +00:00
"time"
2023-06-13 04:15:06 +00:00
"fusenapi/server/shopping-cart-confirmation/internal/config"
"fusenapi/server/shopping-cart-confirmation/internal/handler"
"fusenapi/server/shopping-cart-confirmation/internal/svc"
2023-07-11 11:43:46 +00:00
"fusenapi/utils/auth"
2023-06-13 04:15:06 +00:00
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/shopping-cart-confirmation.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
2023-07-12 02:22:03 +00:00
c.Timeout = int64(time.Second * 15)
2023-06-13 04:15:06 +00:00
2023-07-11 11:43:46 +00:00
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))
2023-06-13 04:15:06 +00:00
defer server.Stop()
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()
}
// var testConfigFile = flag.String("f", "../etc/shopping-cart-confirmation.yaml", "the config file")
// var cnf config.Config
// func GetTestServer() *rest.Server {
// flag.Parse()
// 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
// }