Fix path rewrite on DB change

This commit is contained in:
Florian Duraffourg 2017-01-10 16:14:50 +01:00
parent 577edd86f4
commit 5ffd6d612b

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