Skip to content

Commit

Permalink
move handlers (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
samrabelachew authored Mar 21, 2022
1 parent 5a69d13 commit b05a52e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"context"
"encoding/json"
"fmt"
assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/runatlantis/atlantis/server/static"
"io"
"io/ioutil"
"log"
Expand Down Expand Up @@ -47,7 +49,6 @@ import (
"github.com/runatlantis/atlantis/server/metrics"
"github.com/uber-go/tally"

assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/controllers"
Expand All @@ -71,7 +72,6 @@ import (
lyft_vcs "github.com/runatlantis/atlantis/server/events/vcs/lyft"
"github.com/runatlantis/atlantis/server/events/webhooks"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/static"
"github.com/urfave/cli"
"github.com/urfave/negroni"
)
Expand Down Expand Up @@ -942,6 +942,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
case Worker: // an SQS worker is set up to handle messages via default eventsController
worker, err := sqs.NewGatewaySQSWorker(statsScope, logger, userConfig.LyftWorkerQueueURL, defaultEventsController, ctx)
if err != nil {
logger.With("err", err).Err("unable to set up worker")
cancel()
return nil, errors.Wrapf(err, "setting up sqs handler for worker mode")
}
Expand Down Expand Up @@ -982,16 +983,16 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {

// Start creates the routes and starts serving traffic.
func (s *Server) Start() error {
s.Router.HandleFunc("/", s.Index).Methods("GET").MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool {
return r.URL.Path == "/" || r.URL.Path == "/index.html"
})
s.Router.HandleFunc("/healthz", s.Healthz).Methods("GET")
s.Router.HandleFunc("/status", s.StatusController.Get).Methods("GET")
s.Router.PathPrefix("/static/").Handler(http.FileServer(&assetfs.AssetFS{Asset: static.Asset, AssetDir: static.AssetDir, AssetInfo: static.AssetInfo}))
if s.LyftMode != Worker {
s.Router.HandleFunc("/events", s.VCSPostHandler.Post).Methods("POST")
}
if s.LyftMode != Gateway {
s.Router.HandleFunc("/", s.Index).Methods("GET").MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool {
return r.URL.Path == "/" || r.URL.Path == "/index.html"
})
s.Router.PathPrefix("/static/").Handler(http.FileServer(&assetfs.AssetFS{Asset: static.Asset, AssetDir: static.AssetDir, AssetInfo: static.AssetInfo}))
s.Router.HandleFunc("/apply/lock", s.LocksController.LockApply).Methods("POST").Queries()
s.Router.HandleFunc("/apply/unlock", s.LocksController.UnlockApply).Methods("DELETE").Queries()
s.Router.HandleFunc("/locks", s.LocksController.DeleteLock).Methods("DELETE").Queries("id", "{id:.*}")
Expand Down

0 comments on commit b05a52e

Please sign in to comment.