mirror of
https://github.com/ananthakumaran/paisa.git
synced 2024-09-17 18:39:29 -04:00
28 lines
624 B
Go
28 lines
624 B
Go
package server
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
log "github.com/sirupsen/logrus"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func Listen(db *gorm.DB) {
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
router := gin.Default()
|
|
router.SetTrustedProxies(nil)
|
|
router.Static("/static", "web/static")
|
|
router.StaticFile("/", "web/static/index.html")
|
|
router.GET("/api/overview", func(c *gin.Context) {
|
|
c.JSON(200, GetOverview(db))
|
|
})
|
|
router.GET("/api/investment", func(c *gin.Context) {
|
|
c.JSON(200, GetInvestment(db))
|
|
})
|
|
router.GET("/api/ledger", func(c *gin.Context) {
|
|
c.JSON(200, GetLedger(db))
|
|
})
|
|
log.Info("Listening on 7500")
|
|
router.Run(":7500")
|
|
}
|