Add disconnect endpoint

This commit is contained in:
Dan Sosedoff
2016-02-04 23:05:42 -06:00
parent ccd5455103
commit da43314332
2 changed files with 18 additions and 0 deletions

View File

@@ -114,6 +114,23 @@ func Connect(c *gin.Context) {
c.JSON(200, info.Format()[0])
}
func Disconnect(c *gin.Context) {
conn := DB(c)
if conn == nil {
c.JSON(400, Error{"Not connected"})
return
}
err := conn.Close()
if err != nil {
c.JSON(400, Error{err.Error()})
return
}
c.JSON(200, map[string]bool{"success": true})
}
func GetDatabases(c *gin.Context) {
names, err := DB(c).Databases()
serveResult(names, err, c)