Make things pretty

This commit is contained in:
2016-07-18 01:27:22 +01:00
parent c53b088f19
commit 10873ae9ae
12 changed files with 312 additions and 178 deletions

View File

@@ -25,7 +25,7 @@ func (h *APIHandler) Shorten(c *routing.Context) error {
return h.respondWithError(c, err)
}
r := makeURLResponse(c, uid, url)
r := makeResponse(c, uid, url)
return h.respond(c, &r)
}
@@ -37,11 +37,11 @@ func (h *APIHandler) Lookup(c *routing.Context) error {
return h.respondWithError(c, err)
}
r := makeURLResponse(c, uid, url)
r := makeResponse(c, uid, url)
return h.respond(c, &r)
}
func (h *APIHandler) respond(c *routing.Context, r *URLResponse) error {
func (h *APIHandler) respond(c *routing.Context, r *Response) error {
resp, err := json.Marshal(r)
if err != nil {
return err
@@ -53,10 +53,7 @@ func (h *APIHandler) respond(c *routing.Context, r *URLResponse) error {
}
func (h *APIHandler) respondWithError(c *routing.Context, err error) error {
r := ErrorResponse{
Error: err.Error(),
}
r := Response{Error: err.Error()}
resp, err := json.Marshal(r)
if err != nil {
return err