fix linting issues

This commit is contained in:
Jeffrey Paul 2019-11-08 22:01:59 -08:00
parent a6d2b0ed17
commit 4991ed6ed1
2 changed files with 10 additions and 6 deletions

2
db.go
View File

@ -7,6 +7,8 @@ import "github.com/sneak/merp/models"
import "github.com/rs/zerolog/log"
import _ "github.com/lib/pq" //revive:disable-line
// GetDB returns an orm.Ormer so that the API server can talk to the
// database
func GetDB() orm.Ormer {
if os.Getenv("DEBUG") != "" {
orm.Debug = true

View File

@ -17,6 +17,7 @@ import "github.com/thoas/stats"
import "github.com/astaxie/beego/orm"
import _ "github.com/lib/pq" //revive:disable-line
// Server is the central structure of the HTTP API server.
type Server struct {
db orm.Ormer
debug bool
@ -27,6 +28,7 @@ type Server struct {
thingRegex *regexp.Regexp
}
// NewServer returns a Server, so that you can run the API.
func NewServer() *Server {
ms := new(Server)
ms.init()
@ -75,7 +77,7 @@ func (ms *Server) ServeForever() {
}
}
func (ms *Server) HealthCheckHandler() http.HandlerFunc {
func (ms *Server) healthCheckHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
result := gin.H{
"status": "ok",
@ -92,7 +94,7 @@ func (ms *Server) HealthCheckHandler() http.HandlerFunc {
}
}
func (ms *Server) StatsHandler() http.HandlerFunc {
func (ms *Server) statsHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
stats := ms.stats.Data()
@ -125,10 +127,10 @@ func (ms *Server) setupRoutes() {
ms.stats.End(beginning, stats.WithRecorder(recorder))
})
r.GET("/.well-known/healthcheck.json", gin.WrapF(ms.HealthCheckHandler()))
r.GET("/admin/healthcheck.json", gin.WrapF(ms.HealthCheckHandler()))
r.GET("/admin/stats.json", gin.WrapF(ms.StatsHandler()))
r.GET("/admin/other.json", gin.WrapF(ms.StatsHandler()))
r.GET("/.well-known/healthcheck.json", gin.WrapF(ms.healthCheckHandler()))
r.GET("/admin/healthcheck.json", gin.WrapF(ms.healthCheckHandler()))
r.GET("/admin/stats.json", gin.WrapF(ms.statsHandler()))
r.GET("/admin/other.json", gin.WrapF(ms.statsHandler()))
r.GET("/merp/for/:thing", tollbooth_gin.LimitHandler(limiter), ms.handleNewMerp())
r.GET("/get/latest/merp/for/:thing", tollbooth_gin.LimitHandler(limiter), ms.getLatestMerps())
r.GET("/get/latest/merps", tollbooth_gin.LimitHandler(limiter), ms.getLatestMerps())