package main import ( "context" "flag" "os" "time" "git.chuangxin1.com/csacred/toolkit" "git.chuangxin1.com/csacred/toolkit/http" "github.com/go-kit/kit/log" ) func main() { var ( addr = flag.String("listen", ":9999", "Address for HTTP server") consulAddr = flag.String("consul", "", "Consul agent address") ) flag.Parse() // Logging domain. var logger log.Logger { logger = log.NewLogfmtLogger(os.Stderr) logger = log.With(logger, "ts", log.DefaultTimestampUTC) logger = log.With(logger, "caller", log.DefaultCaller) } router := http.NewRouter() ctx := context.Background() options := toolkit.ServiceOptions{} if len(*consulAddr) > 0 { options.Address = *consulAddr } genUserHandlers(ctx, router, options, logger) //genWechatHandlers(ctx, router, options, logger) var ( readTimeout time.Duration writeTimeout time.Duration maxHeaderBytes int ) readTimeout = 5 * time.Second writeTimeout = 10 * time.Second maxHeaderBytes = 1024 * 1024 http.ListenAndServe(*addr, router, readTimeout, writeTimeout, maxHeaderBytes, logger) }