diff --git a/main.go b/main.go index 897f401..3b7871c 100644 --- a/main.go +++ b/main.go @@ -1,23 +1,20 @@ package main import ( + "net/http" "time" "github.com/celestiaorg/supply/internal" "github.com/gin-gonic/gin" ) -const landingPage = ` -Available routes are: -/v0/circulating-supply -/v0/total-supply +const ( + // RouteCirculatingSupply is the route for circulating supply. + RouteCirculatingSupply = "/v0/circulating-supply" -Note: all routes return values in TIA. -` - -func getLandingPage(c *gin.Context) { - c.String(200, landingPage) -} + // RouteTotalSupply is the route for total supply. + RouteTotalSupply = "/v0/total-supply" +) func getCirculatingSupply(c *gin.Context) { t := time.Now() @@ -33,9 +30,15 @@ func getTotalSupply(c *gin.Context) { func main() { router := gin.Default() - router.GET("/", getLandingPage) - router.GET("/v0/circulating-supply", getCirculatingSupply) - router.GET("/v0/total-supply", getTotalSupply) + router.LoadHTMLGlob("templates/*") + router.GET("/", func(c *gin.Context) { + c.HTML(http.StatusOK, "index.tmpl", gin.H{ + "RouteCirculatingSupply": RouteCirculatingSupply, + "RouteTotalSupply": RouteTotalSupply, + }) + }) + router.GET(RouteCirculatingSupply, getCirculatingSupply) + router.GET(RouteTotalSupply, getTotalSupply) err := router.Run("0.0.0.0:8080") if err != nil { panic(err) diff --git a/templates/index.tmpl b/templates/index.tmpl new file mode 100644 index 0000000..bee2669 --- /dev/null +++ b/templates/index.tmpl @@ -0,0 +1,7 @@ + + These routes return values in TIA: +
+