Skip to content

Commit

Permalink
Clean up imports, add gzip middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
tooolbox committed May 26, 2020
1 parent fcaef3a commit c9a012f
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 32 deletions.
8 changes: 5 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"github.com/ajvb/kala/api/middleware"
"github.com/ajvb/kala/job"

"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"github.com/phyber/negroni-gzip/gzip"
log "github.com/sirupsen/logrus"
"github.com/urfave/negroni"
)

const (
Expand Down Expand Up @@ -327,8 +328,6 @@ func MakeServer(listenAddr string, cache job.JobCache, db job.JobDB, defaultOwne
r.StrictSlash(true)
SetupApiRoutes(r, cache, db, defaultOwner)
r.PathPrefix("/webui/").Handler(http.StripPrefix("/webui/", http.FileServer(http.Dir("./webui/"))))
n := negroni.New(negroni.NewRecovery(), &middleware.Logger{log.Logger{}})
n.UseHandler(r)

if profile {
runtime.SetMutexProfileFraction(5)
Expand All @@ -345,6 +344,9 @@ func MakeServer(listenAddr string, cache job.JobCache, db job.JobDB, defaultOwne
r.Handle("/debug/pprof/mutex", pprof.Handler("mutex"))
}

n := negroni.New(negroni.NewRecovery(), &middleware.Logger{log.Logger{}}, gzip.Gzip(gzip.DefaultCompression))
n.UseHandler(r)

return &http.Server{
Addr: listenAddr,
Handler: n,
Expand Down
2 changes: 1 addition & 1 deletion api/middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"net/http"
"time"

"github.com/codegangsta/negroni"
log "github.com/sirupsen/logrus"
"github.com/urfave/negroni"
)

// Logger is a middleware handler that logs the request as it goes in and the response as it goes out.
Expand Down
2 changes: 1 addition & 1 deletion cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"github.com/ajvb/kala/job/storage/postgres"
"github.com/ajvb/kala/job/storage/redis"

"github.com/codegangsta/cli"
redislib "github.com/garyburd/redigo/redis"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
"gopkg.in/mgo.v2"
)

Expand Down
26 changes: 14 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,33 @@ go 1.13

require (
github.com/DATA-DOG/go-sqlmock v1.3.0
github.com/armon/go-metrics v0.3.3 // indirect
github.com/boltdb/bolt v1.3.1-0.20170131192018-e9cf4fae01b5
github.com/codegangsta/cli v1.8.1-0.20150711215404-bca61c476e3c
github.com/codegangsta/negroni v0.1.1-0.20150319171304-c7477ad8e330
github.com/cornelk/hashmap v1.0.1
github.com/dchest/siphash v1.1.0
github.com/garyburd/redigo v1.0.1-0.20170208211623-48545177e92a
github.com/go-sql-driver/mysql v1.4.1
github.com/gorilla/context v0.0.0-20141217160251-215affda49ad
github.com/gorilla/context v0.0.0-20141217160251-215affda49ad // indirect
github.com/gorilla/mux v0.0.0-20150808061613-ffb3f683aad4
github.com/hashicorp/consul v0.9.1-0.20170720214845-3117d9ec2b86
github.com/hashicorp/go-cleanhttp v0.0.0-20170211013415-3573b8b52aa7
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90
github.com/hashicorp/serf v0.8.2-0.20170714182601-bbeddf0b3ab3
github.com/hashicorp/go-msgpack v1.1.5 // indirect
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/memberlist v0.2.2 // indirect
github.com/hashicorp/serf v0.8.2-0.20170714182601-bbeddf0b3ab3 // indirect
github.com/jmoiron/sqlx v1.2.0
github.com/lestrrat-go/tcputil v0.0.0-20180223003554-d3c7f98154fb // indirect
github.com/lestrrat-go/test-mysqld v0.0.0-20190527004737-6c91be710371
github.com/lib/pq v1.0.0
github.com/mattn/go-shellwords v1.0.0
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747
github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 // indirect
github.com/mixer/clock v0.0.0-20190507173039-c311c17adb1f
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/pkg/errors v0.8.1 // indirect
github.com/phyber/negroni-gzip v0.0.0-20180113114010-ef6356a5d029
github.com/rafaeljusto/redigomock v0.0.0-20170720131524-7ae0511314e9
github.com/sirupsen/logrus v0.11.3-0.20170215164324-7f4b1adc7917
github.com/stretchr/testify v0.0.0-20150812162424-f5520455607c
golang.org/x/sys v0.0.0-20161023150541-c200b10b5d5e
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.4
github.com/urfave/negroni v1.0.0
google.golang.org/appengine v1.6.6 // indirect
gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528
)
Loading

0 comments on commit c9a012f

Please sign in to comment.