fusenapi/goctl_template/api/main.tpl

46 lines
897 B
Smarty
Raw Normal View History

2023-06-05 09:56:55 +00:00
package main
import (
"flag"
"fmt"
{{.importPackages}}
)
var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
server := rest.MustNewServer(c.RestConf)
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()
}
2023-06-12 10:08:34 +00:00
// var testConfigFile = flag.String("f", "../etc/{{.serviceName}}.yaml", "the config file")
// func GetTestServer() *rest.Server {
// flag.Parse()
// var c config.Config
// conf.MustLoad(*testConfigFile, &c)
// server := rest.MustNewServer(c.RestConf)
// defer server.Stop()
// ctx := svc.NewServiceContext(c)
// handler.RegisterHandlers(server, ctx)
// fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
// return server
// }