add sync api for syncing trades in the background

This commit is contained in:
c9s 2021-02-20 11:56:39 +08:00
parent 7684099f01
commit c72b7b2dfa

View File

@ -76,6 +76,18 @@ func (s *Server) newEngine() *gin.Engine {
})
})
r.POST("/api/environment/sync", func(c *gin.Context) {
go func() {
if err := s.Environ.Sync(context.Background()) ; err != nil {
logrus.WithError(err).Error("sync error")
}
}()
c.JSON(http.StatusOK, gin.H{
"success": true,
})
})
r.GET("/api/trades", func(c *gin.Context) {
if s.Environ.TradeService == nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "database is not configured"})