Commits

Miki Tebeka committed 86806c8

use newShortURL

Comments (0)

Files changed (1)

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)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.