add Metric
This commit is contained in:
13
internal/services/api/handler_metrics.go
Normal file
13
internal/services/api/handler_metrics.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"thuanle.me/ip-info/internal/services/db_updater"
|
||||
)
|
||||
|
||||
func HandleMetrics(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"updated_at": db_updater.DbUpdatedAt.UnixMilli(),
|
||||
})
|
||||
}
|
||||
@@ -24,6 +24,7 @@ func StartApiService() {
|
||||
|
||||
engine.GET("/", HandleIp)
|
||||
engine.GET("/json", HandleJson)
|
||||
engine.GET("/metrics", HandleMetrics)
|
||||
|
||||
port := os.Getenv(key.EnvApiPort)
|
||||
if len(port) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user