Exemple #1
0
func NewSource(opts ...SourceOption) Source {
	var options SourceOptions
	for _, o := range opts {
		o(&options)
	}

	if len(options.Name) == 0 {
		options.Name = DefaultSourceName
	}

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

	return &source{
		opts:   options,
		client: proto.NewConfigClient("go.micro.srv.config", options.Client),
	}
}
Exemple #2
0
func web(ctx *cli.Context) {
	opts := []gweb.Option{
		gweb.Name("go.micro.web.config"),
		gweb.Handler(whandler.Router()),
	}

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

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

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

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

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