// NewDefault creates a new `Server` using `config.hcl`. func NewDefault() (srv *Server, err error) { cfg := config.DefaultConfig() cl, err := client.New(cfg) if err != nil { return nil, err } srv = New(cfg, cl) return }
// New creates a `Client` with an empty `FeatureMap` and `Config`. func New() (d *Client) { c, _ := client.New(&config.Config{ Watcher: config.Watcher{ OutputPath: "", }, }) d = &Client{ Client: *c, featureMap: models.EmptyFeatureMap(), } d.Client.SetFeatureMap(d.featureMap) return }
func (cc *Controller) Serve(ctx climax.Context) int { c, err := client.New(cc.Config) if err != nil { printer.LogErrf("%v", err) } s := server.New(cc.Config, c) printer.Logf("pid: %d serving %s on %s", os.Getpid(), cc.Config.Server.Endpoint, cc.Config.Server.Host) err = s.Serve() if err != nil { printer.LogErrf("%v", err) return 1 } return 0 }
"time" "github.com/stretchr/testify/assert" "github.com/vsco/dcdr/client" "github.com/vsco/dcdr/config" "github.com/vsco/dcdr/models" "github.com/vsco/dcdr/server/handlers" "github.com/vsco/dcdr/server/middleware" http_assert "github.com/vsco/http-test/assert" "github.com/vsco/http-test/builder" ) var fm = models.EmptyFeatureMap() var cfg = config.TestConfig() var cl, _ = client.New(cfg) func mockServer() *Server { cl.SetFeatureMap(fm) return New(cfg, cl) } func TestGetFeatures(t *testing.T) { srv := mockServer() resp := builder.WithMux(srv).Get(srv.config.Server.Endpoint).Do() http_assert.Response(t, resp.Response). IsOK(). IsJSON() var m models.FeatureMap err := resp.Response.UnmarshalBody(&m)