Globally renamed property RedirectUrl to LongUrl

This commit is contained in:
strNophix 2022-08-27 14:16:23 +02:00
parent 590906d555
commit 092cbcfdd1
7 changed files with 14 additions and 14 deletions

@ -12,14 +12,14 @@ type (
}
ExpandResp {
RedirectUrl string `json:"redirectUrl"`
LongUrl string `json:"longUrl"`
}
)
type (
ShortenReq {
RedirectUrl string `json:"redirectUrl"`
ExpiresIn int64 `json:"expiresIn,optional"`
LongUrl string `json:"longUrl"`
ExpiresIn int64 `json:"expiresIn,optional"`
}
ShortenResp {

@ -4,12 +4,12 @@ import "github.com/scylladb/gocqlx/v2/table"
var UrlTable = table.New(table.Metadata{
Name: "fivefeeteleven.urls",
Columns: []string{"id", "redirect_url"},
Columns: []string{"id", "long_url"},
PartKey: []string{"id"},
SortKey: []string{},
})
type UrlModel struct {
ID string
RedirectUrl string
ID string
LongUrl string
}

@ -15,7 +15,7 @@ func Seed(session gocqlx.Session) error {
err = session.ExecStmt(`
CREATE TABLE IF NOT EXISTS fivefeeteleven.urls (
id text PRIMARY KEY,
redirect_url text
long_url text
)`)
if err != nil {

@ -23,7 +23,7 @@ func ExpandUrlHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
if err != nil {
httpx.Error(w, err)
} else {
http.Redirect(w, r, resp.RedirectUrl, http.StatusTemporaryRedirect)
http.Redirect(w, r, resp.LongUrl, http.StatusTemporaryRedirect)
}
}
}

@ -39,7 +39,7 @@ func (l *ExpandUrlLogic) ExpandUrl(req *types.ExpandReq) (resp *types.ExpandResp
}
resp = &types.ExpandResp{
RedirectUrl: urls[0].RedirectUrl,
LongUrl: urls[0].LongUrl,
}
return resp, err

@ -30,8 +30,8 @@ func (l *ShortenUrlLogic) ShortenUrl(req *types.ShortenReq) (resp *types.Shorten
insertUrl := db.UrlTable.InsertBuilder().TTL(30 * time.Second).Query(l.svcCtx.DB)
insertUrl.BindStruct(db.UrlModel{
ID: id,
RedirectUrl: req.RedirectUrl,
ID: id,
LongUrl: req.LongUrl,
})
if err := insertUrl.ExecRelease(); err != nil {

@ -6,12 +6,12 @@ type ExpandReq struct {
}
type ExpandResp struct {
RedirectUrl string `json:"redirectUrl"`
LongUrl string `json:"longUrl"`
}
type ShortenReq struct {
RedirectUrl string `json:"redirectUrl"`
ExpiresIn int64 `json:"expiresIn,optional"`
LongUrl string `json:"longUrl"`
ExpiresIn int64 `json:"expiresIn,optional"`
}
type ShortenResp struct {