add /api/environment/syncing api

This commit is contained in:
c9s 2021-02-20 11:54:48 +08:00
parent b158884708
commit 7684099f01
2 changed files with 9 additions and 0 deletions

View File

@ -448,6 +448,9 @@ func (environ *Environment) Connect(ctx context.Context) error {
}
func (environ *Environment) IsSyncing() bool {
environ.syncMutex.Lock()
defer environ.syncMutex.Unlock()
return environ.syncing
}

View File

@ -70,6 +70,12 @@ func (s *Server) newEngine() *gin.Engine {
r.POST("/api/setup/restart", s.setupRestart)
}
r.GET("/api/environment/syncing", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"syncing": s.Environ.IsSyncing(),
})
})
r.GET("/api/trades", func(c *gin.Context) {
if s.Environ.TradeService == nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "database is not configured"})