示例#1
0
func newPlatform(opts ...Option) Event {
	var options Options
	for _, o := range opts {
		o(&options)
	}

	if options.Client == nil {
		options.Client = client.DefaultClient
	}

	return &platform{
		opts: options,
		cl:   ev.NewEventClient("go.micro.srv.event", options.Client),
	}
}
示例#2
0
文件: event.go 项目: micro/platform
func web(ctx *cli.Context) {
	opts := []gweb.Option{
		gweb.Name("go.micro.web.event"),
		gweb.Handler(whandler.Router()),
	}

	opts = append(opts, helper.WebOpts(ctx)...)

	templateDir := "event/templates"
	if dir := ctx.GlobalString("html_dir"); len(dir) > 0 {
		templateDir = dir
	}

	whandler.Init(
		templateDir,
		proto.NewEventClient("go.micro.srv.event", *cmd.DefaultOptions().Client),
	)

	service := gweb.NewService(opts...)

	if err := service.Run(); err != nil {
		log.Fatal(err)
	}
}