Record query history

This commit is contained in:
Dan Sosedoff 2014-10-09 19:59:18 -05:00
parent 3d2245f416
commit 50230be564

View File

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