26 lines
433 B
Go
26 lines
433 B
Go
package api
|
|
|
|
import (
|
|
"app/database"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (api *Api) defineRoutes() {
|
|
api.Router.GET("/ping", func(c *gin.Context) {
|
|
c.JSON(200, gin.H{
|
|
"message": "pong",
|
|
})
|
|
})
|
|
}
|
|
|
|
func (api *Api) initialize() {
|
|
api.Database = database.Database{Location: "sqlite.db"}
|
|
api.Database.Initialize()
|
|
}
|
|
|
|
func (api *Api) Run() {
|
|
api.initialize()
|
|
api.Router = gin.Default()
|
|
api.defineRoutes()
|
|
api.Router.Run()
|
|
}
|