package internal import ( "net/http" "github.com/julienschmidt/httprouter" "github.com/unrolled/render" ) // API ... type API struct { router *Router config *Config db Store r *render.Render } // NewAPI ... func NewAPI(router *Router, config *Config, db Store) *API { api := &API{router, config, db, render.New()} api.initRoutes() return api } func (a *API) initRoutes() { router := a.router.Group("/api/v1") router.GET("/ping", a.PingEndpoint()) } // PingEndpoint ... func (a *API) PingEndpoint() httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { w.Header().Set("Content-Type", "application/json") _, _ = w.Write([]byte(`{}`)) } }