Commits

Miki Tebeka  committed 86806c8

use newShortURL

  • Participants
  • Parent commits fe771c1

Comments (0)

Files changed (1)

File 5-short/shortie/shortie.go

 		}
 
 		var id string
-		id, err = nextId(ctx)
-
+		id, err = newShortURL(ctx, id, longURL)
 		if err != nil {
 			return
 		}
 
-		url := &URL{
-			Short:   id,
-			Long:    longURL,
-			User:    params.User,
-			Created: time.Now(),
-			Hits:    0,
-		}
-		key := datastore.NewKey(ctx, urlKind, id, 0, nil)
-		_, err = datastore.Put(ctx, key, url)
-		if err != nil {
-			return
-		}
 		params.ShortURL = fullURL(r, id)
 	}
 }
 	return fmt.Sprintf("http://%s/%s", r.Host, id)
 }
 
-func newShortUrl(ctx appengine.Context, longURL, user string) (string, error) {
+func newShortURL(ctx appengine.Context, longURL, user string) (string, error) {
 	var id string
 	id, err := nextId(ctx)