Merge pull request #212 from fduraffourg/SwitchDb

Fix path rewrite on DB change
This commit is contained in:
Dan Sosedoff
2017-01-10 10:49:00 -06:00
committed by GitHub
+2 -3
View File
@@ -5,7 +5,6 @@ import (
"errors" "errors"
"fmt" "fmt"
neturl "net/url" neturl "net/url"
"strings"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@@ -147,9 +146,9 @@ func SwitchDb(c *gin.Context) {
return return
} }
newStr := strings.Replace(conn.ConnectionString, currentUrl.Path, "/"+name, 1) currentUrl.Path = name
cl, err := client.NewFromUrl(newStr, nil) cl, err := client.NewFromUrl(currentUrl.String(), nil)
if err != nil { if err != nil {
c.JSON(400, Error{err.Error()}) c.JSON(400, Error{err.Error()})
return return