go-zero/example/shorturl/api/shorturl.go
2020-09-01 16:04:39 +08:00

29 lines
523 B
Go

package main
import (
"flag"
"shorturl/api/internal/config"
"shorturl/api/internal/handler"
"shorturl/api/internal/svc"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/rest"
)
var configFile = flag.String("f", "etc/shorturl-api.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
server := rest.MustNewServer(c.RestConf)
defer server.Stop()
handler.RegisterHandlers(server, ctx)
server.Start()
}