From 21bcc6e4b8df9879919d22d38849edfb17437f20 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Fri, 17 Oct 2014 20:30:08 -0700 Subject: [PATCH] Add /tables/:name/info endpoint to get table data details --- api.go | 11 +++++++++++ main.go | 1 + 2 files changed, 12 insertions(+) diff --git a/api.go b/api.go index 42d2a53..6a24fe5 100644 --- a/api.go +++ b/api.go @@ -89,6 +89,17 @@ func API_GetTable(c *gin.Context) { c.JSON(200, res) } +func API_GetTableInfo(c *gin.Context) { + res, err := dbClient.TableInfo(c.Params.ByName("table")) + + if err != nil { + c.JSON(400, NewError(err)) + return + } + + c.JSON(200, res) +} + func API_History(c *gin.Context) { c.JSON(200, dbClient.history) } diff --git a/main.go b/main.go index 40564bc..eaf4d8e 100644 --- a/main.go +++ b/main.go @@ -82,6 +82,7 @@ func startServer() { router.GET("/info", API_Info) router.GET("/tables", API_GetTables) router.GET("/tables/:table", API_GetTable) + router.GET("/tables/:table/info", API_GetTableInfo) router.GET("/tables/:table/indexes", API_TableIndexes) router.GET("/query", API_RunQuery) router.POST("/query", API_RunQuery)