Exemple #1
0
func newServer(cy *conveyor.Conveyor, c *cli.Context) http.Handler {
	var apiAuth func(http.Handler) http.Handler

	if auth := c.String("auth"); auth != "" {
		parts := strings.Split(auth, ":")
		apiAuth = httpauth.SimpleBasicAuth(parts[0], parts[1])
	} else {
		apiAuth = func(h http.Handler) http.Handler { return h }
	}

	r := mux.NewRouter()
	r.NotFoundHandler = server.NewServer(cy, server.Config{
		APIAuth:      apiAuth,
		GitHubSecret: c.String("github.secret"),
	})

	// Slack webhooks
	if c.String("slack.token") != "" {
		r.Handle("/slack", newSlackServer(cy, c))
	}

	n := negroni.Classic()
	n.UseHandler(r)

	return n
}
Exemple #2
0
func newClient(t testing.TB) *Client {
	c := newConveyor(t)
	s := httptest.NewServer(server.NewServer(c.Conveyor, server.Config{
		APIAuth: func(h http.Handler) http.Handler { return h },
	}))

	cl := conveyor.NewService(conveyor.DefaultClient)
	cl.URL = s.URL

	return &Client{
		Service: cl,
		s:       s,
		c:       c,
	}
}
Exemple #3
0
func newServer(cy *conveyor.Conveyor, c *cli.Context) http.Handler {
	r := mux.NewRouter()
	r.NotFoundHandler = server.NewServer(cy, server.Config{
		GitHubSecret: c.String("github.secret"),
		Logger:       newLogger(c),
	})

	// Slack webhooks
	if c.String("slack.token") != "" {
		r.Handle("/slack", newSlackServer(cy, c))
	}

	n := negroni.Classic()
	n.UseHandler(r)

	return n
}