Add /explain endpoint

This commit is contained in:
Dan Sosedoff
2014-10-11 13:24:12 -05:00
parent d786919a36
commit e2bc79f686
2 changed files with 13 additions and 0 deletions

11
api.go
View File

@@ -22,6 +22,17 @@ func API_RunQuery(c *gin.Context) {
API_HandleQuery(query, c)
}
func API_ExplainQuery(c *gin.Context) {
query := strings.TrimSpace(c.Request.FormValue("query"))
if query == "" {
c.JSON(400, errors.New("Query parameter is missing"))
return
}
API_HandleQuery(fmt.Sprintf("EXPLAIN %s", query), c)
}
func API_GetTables(c *gin.Context) {
names, err := dbClient.Tables()