diff --git a/go.mod b/go.mod index c4f17e6..0871089 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,10 @@ module github.com/jenkins-x/jx-cdevents-adapter go 1.19 +require github.com/sirupsen/logrus v1.9.0 + require ( - github.com/gorilla/mux v1.8.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect + github.com/go-chi/chi/v5 v5.0.8 golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect ) diff --git a/go.sum b/go.sum index bebfac9..d008b74 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,18 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/go-chi/chi/v5 v5.0.8 h1:lD+NLqFcAi1ovnVZpsnObHGW4xb4J8lNmoYVfECH1Y0= +github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= \ No newline at end of file +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= + diff --git a/handlers/handlers.go b/handlers/handlers.go index 122a40d..62f1174 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -3,17 +3,18 @@ package handlers import ( "sync/atomic" - "github.com/gorilla/mux" + "github.com/go-chi/chi/v5" ) // Router register necessary routes and returns an instance of a router. -func Router() *mux.Router { - r := mux.NewRouter() +func Router() *chi.Mux { + + r := chi.NewRouter() isReady := &atomic.Value{} isReady.Store(true) - r.HandleFunc("/", home).Methods("POST") - r.HandleFunc("/healthz", healthz) - r.HandleFunc("/readyz", readyz(isReady)) + r.Post("/", home) + r.Get("/healthz", healthz) + r.Get("/readyz", readyz(isReady)) return r } diff --git a/main.go b/main.go index d212f16..b455507 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ func handleRequests() { port, found := os.LookupEnv("ADAPTER_PORT") if !found || port == "" { - port = "80" + port = "8080" } router := handlers.Router()