diff --git a/main.go b/main.go index f7bc9d3..3b1ef87 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ type Error struct { } var dbClient *Client +var history []string var options struct { Host string `short:"h" long:"host" description:"Server hostname or IP" default:"localhost"` @@ -122,6 +123,8 @@ func API_RunQuery(c *gin.Context) { return } + history = append(history, query) + API_HandleQuery(query, c) } @@ -138,6 +141,10 @@ func API_GetTable(c *gin.Context) { API_HandleQuery(query, c) } +func API_History(c *gin.Context) { + c.JSON(200, history) +} + func API_HandleQuery(query string, c *gin.Context) { result, err := dbClient.Query(query) @@ -186,6 +193,7 @@ func main() { router.GET("/tables/:name", API_GetTable) router.GET("/select", API_RunQuery) router.POST("/select", API_RunQuery) + router.GET("/history", API_History) router.Static("/app", options.Static)