mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
Refactor shortner and web packages for new Store interface
This commit is contained in:
@@ -20,24 +20,24 @@ type APIHandler struct {
|
||||
|
||||
// Shorten shortens given URL.
|
||||
func (h *APIHandler) Shorten(c *routing.Context) error {
|
||||
uid, url, err := h.shortener.Shorten(c.FormValue("url"))
|
||||
record, err := h.shortener.Shorten(c.FormValue("url"))
|
||||
if err != nil {
|
||||
return h.respondWithError(c, err)
|
||||
}
|
||||
|
||||
r := makeResponse(c, uid, url)
|
||||
r := makeResponse(c, record)
|
||||
return h.respond(c, &r)
|
||||
}
|
||||
|
||||
// Lookup shortened UID.
|
||||
func (h *APIHandler) Lookup(c *routing.Context) error {
|
||||
uid := c.FormValue("uid")
|
||||
url, err := h.shortener.Lookup(uid)
|
||||
record, err := h.shortener.Lookup(uid)
|
||||
if err != nil {
|
||||
return h.respondWithError(c, err)
|
||||
}
|
||||
|
||||
r := makeResponse(c, uid, url)
|
||||
r := makeResponse(c, record)
|
||||
return h.respond(c, &r)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user