Rename response attributes

This commit is contained in:
2016-07-11 19:20:10 +01:00
parent fa9b0dfab3
commit 9d636cafab
3 changed files with 12 additions and 12 deletions

View File

@@ -71,9 +71,9 @@ func (h *Handlers) LookupAndRedirect(c *routing.Context) error {
func (h *Handlers) respondWithShortened(c *routing.Context, uid []byte, url []byte) { func (h *Handlers) respondWithShortened(c *routing.Context, uid []byte, url []byte) {
c.SetStatusCode(fasthttp.StatusOK) c.SetStatusCode(fasthttp.StatusOK)
response := ShortenedResponse{ response := ShortenedResponse{
UID: string(uid), UID: string(uid),
ShortURL: h.makeShortURL(c, uid), URL: h.makeShortURL(c, uid),
URL: string(url), Target: string(url),
} }
respBytes, _ := json.Marshal(response) respBytes, _ := json.Marshal(response)
c.Write(respBytes) c.Write(respBytes)

View File

@@ -4,9 +4,9 @@ package web
// ShortenedResponse contains shortened URL info. // ShortenedResponse contains shortened URL info.
type ShortenedResponse struct { type ShortenedResponse struct {
UID string `json:"uid"` UID string `json:"uid"`
ShortURL string `json:"short_url"` URL string `json:"url"`
URL string `json:"url"` Target string `json:"target"`
} }
// ErrorResponse contains error info. // ErrorResponse contains error info.

View File

@@ -79,10 +79,10 @@ func easyjson_559270ae_decode_github_com_jimeh_ozu_io_web_ShortenedResponse(in *
switch key { switch key {
case "uid": case "uid":
out.UID = string(in.String()) out.UID = string(in.String())
case "short_url":
out.ShortURL = string(in.String())
case "url": case "url":
out.URL = string(in.String()) out.URL = string(in.String())
case "target":
out.Target = string(in.String())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@@ -104,14 +104,14 @@ func easyjson_559270ae_encode_github_com_jimeh_ozu_io_web_ShortenedResponse(out
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"short_url\":") out.RawString("\"url\":")
out.String(string(in.ShortURL)) out.String(string(in.URL))
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"url\":") out.RawString("\"target\":")
out.String(string(in.URL)) out.String(string(in.Target))
out.RawByte('}') out.RawByte('}')
} }
func (v ShortenedResponse) MarshalJSON() ([]byte, error) { func (v ShortenedResponse) MarshalJSON() ([]byte, error) {