renamed type as recommended to avoid stuttering

This commit is contained in:
Jeffrey Paul 2019-11-08 21:59:16 -08:00
parent c7e2f8c4f3
commit a6d2b0ed17
3 changed files with 12 additions and 12 deletions

View File

@ -25,7 +25,7 @@ func main() {
wg.Add(1)
go func() {
ms := merp.NewMerpServer()
ms := merp.NewServer()
ms.ServeForever()
wg.Done()
}()

View File

@ -20,7 +20,7 @@ func decodeJSON(in []byte) (interface{}, error) {
return out, nil
}
func (ms *MerpServer) getLatestMerps() gin.HandlerFunc {
func (ms *Server) getLatestMerps() gin.HandlerFunc {
return func(c *gin.Context) {
thing := c.Param("thing")
if thing != "" {
@ -67,7 +67,7 @@ func (ms *MerpServer) getLatestMerps() gin.HandlerFunc {
}
}
func (ms *MerpServer) handleNewMerp() gin.HandlerFunc {
func (ms *Server) handleNewMerp() gin.HandlerFunc {
return func(c *gin.Context) {
// request time
thing := c.Param("thing")

View File

@ -17,7 +17,7 @@ import "github.com/thoas/stats"
import "github.com/astaxie/beego/orm"
import _ "github.com/lib/pq" //revive:disable-line
type MerpServer struct {
type Server struct {
db orm.Ormer
debug bool
gin *gin.Engine
@ -27,13 +27,13 @@ type MerpServer struct {
thingRegex *regexp.Regexp
}
func NewMerpServer() *MerpServer {
ms := new(MerpServer)
func NewServer() *Server {
ms := new(Server)
ms.init()
return ms
}
func (ms *MerpServer) init() {
func (ms *Server) init() {
ms.thingRegex = regexp.MustCompile(`^[a-zA-Z0-9\_\-]+$`)
@ -63,19 +63,19 @@ func (ms *MerpServer) init() {
}
}
func (ms *MerpServer) connectDB() {
func (ms *Server) connectDB() {
ms.db = GetDB()
}
// ServeForever causes merp to serve http forever
func (ms *MerpServer) ServeForever() {
func (ms *Server) ServeForever() {
err := ms.server.ListenAndServe()
if err != nil {
panic(err)
}
}
func (ms *MerpServer) HealthCheckHandler() http.HandlerFunc {
func (ms *Server) HealthCheckHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
result := gin.H{
"status": "ok",
@ -92,7 +92,7 @@ func (ms *MerpServer) HealthCheckHandler() http.HandlerFunc {
}
}
func (ms *MerpServer) 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()
@ -101,7 +101,7 @@ func (ms *MerpServer) StatsHandler() http.HandlerFunc {
}
}
func (ms *MerpServer) setupRoutes() {
func (ms *Server) setupRoutes() {
if !ms.debug {
gin.SetMode(gin.ReleaseMode)
}