Add test for serverResult func

This commit is contained in:
Dan Sosedoff
2018-11-05 17:07:32 -06:00
parent 9ca959c31c
commit abb143601b
3 changed files with 54 additions and 20 deletions

View File

@@ -7,7 +7,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/sosedoff/pgweb/pkg/command"
"github.com/sosedoff/pgweb/pkg/data"
)
// Middleware function to check database connection status before running queries
@@ -58,25 +57,6 @@ func requestInspectMiddleware() gin.HandlerFunc {
}
}
func serveStaticAsset(path string, c *gin.Context) {
data, err := data.Asset("static" + path)
if err != nil {
c.String(400, err.Error())
return
}
c.Data(200, assetContentType(path), data)
}
func serveResult(result interface{}, err error, c *gin.Context) {
if err != nil {
c.JSON(400, NewError(err))
return
}
c.JSON(200, result)
}
func corsMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
c.Header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")