Ejemplo n.º 1
0
func New(e *empire.Empire, options Options) http.Handler {
	r := httpx.NewRouter()

	if options.GitHub.Webhooks.Secret != "" {
		// Mount GitHub webhooks
		g := github.New(e, github.Options{
			Secret:        options.GitHub.Webhooks.Secret,
			Environment:   options.GitHub.Deployments.Environment,
			ImageTemplate: options.GitHub.Deployments.ImageTemplate,
			TugboatURL:    options.GitHub.Deployments.TugboatURL,
		})
		r.Match(githubWebhook, g)
	}

	// Mount the heroku api
	h := heroku.New(e, options.Authenticator)
	r.Headers("Accept", heroku.AcceptHeader).Handler(h)

	// Mount health endpoint
	r.Handle("/health", NewHealthHandler(e))

	return middleware.Common(r, middleware.CommonOpts{
		Reporter: e.Reporter,
		Logger:   e.Logger,
	})
}
Ejemplo n.º 2
0
func New(e *empire.Empire, options Options) *Server {
	r := httpx.NewRouter()
	s := &Server{mux: r}

	if options.GitHub.Webhooks.Secret != "" {
		// Mount GitHub webhooks
		g := github.New(e, github.Options{
			Secret:       options.GitHub.Webhooks.Secret,
			Environments: options.GitHub.Deployments.Environments,
			Deployer:     newDeployer(e, options),
		})
		r.Match(githubWebhook, g)
	}

	// Mount the heroku api
	s.Heroku = heroku.New(e)
	r.Headers("Accept", heroku.AcceptHeader).Handler(s.Heroku)

	// Mount SAML handlers.
	r.HandleFunc("/saml/login", s.SAMLLogin)
	r.HandleFunc("/saml/acs", s.SAMLACS)

	// Mount health endpoint
	r.Handle("/health", NewHealthHandler(e))

	return s
}
Ejemplo n.º 3
0
func New(e *empire.Empire, options Options) httpx.Handler {
	r := httpx.NewRouter()

	if options.GitHub.Webhooks.Secret != "" {
		// Mount GitHub webhooks
		g := github.New(e, github.Options{
			Secret:       options.GitHub.Webhooks.Secret,
			Environments: options.GitHub.Deployments.Environments,
			Deployer:     newDeployer(e, options),
		})
		r.Match(githubWebhook, g)
	}

	// Mount the heroku api
	hk := heroku.New(e, options.Authenticator)
	r.Headers("Accept", heroku.AcceptHeader).Handler(hk)

	// Mount health endpoint
	r.Handle("/health", NewHealthHandler(e))

	return r
}
Ejemplo n.º 4
0
func New(e *empire.Empire, options Options) http.Handler {
	r := httpx.NewRouter()

	auth := NewAuthorizer(
		options.GitHub.ClientID,
		options.GitHub.ClientSecret,
		options.GitHub.Organization,
		options.GitHub.ApiURL,
	)

	// Mount the heroku api
	h := heroku.New(e, auth)
	r.Headers("Accept", heroku.AcceptHeader).Handler(h)

	// Mount health endpoint
	r.Handle("/health", NewHealthHandler(e))

	return middleware.Common(r, middleware.CommonOpts{
		Reporter: e.Reporter,
		Logger:   e.Logger,
	})
}