Skip to content

Commit

Permalink
feat: landing page links
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Nov 20, 2023
1 parent 950e156 commit f2df3ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
29 changes: 16 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions templates/index.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
These routes return values in TIA:
<ul>
<li><a href={{ .RouteCirculatingSupply }}>{{ .RouteCirculatingSupply }}</a></li>
<li><a href={{ .RouteTotalSupply }}>{{ .RouteTotalSupply }}</a></li>
</ul>
</html>

0 comments on commit f2df3ed

Please sign in to comment.