mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-15 03:36:33 +03:00
Record query history
This commit is contained in:
parent
3d2245f416
commit
50230be564
8
main.go
8
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user