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) {
c.SetStatusCode(fasthttp.StatusOK)
response := ShortenedResponse{
UID: string(uid),
ShortURL: h.makeShortURL(c, uid),
URL: string(url),
UID: string(uid),
URL: h.makeShortURL(c, uid),
Target: string(url),
}
respBytes, _ := json.Marshal(response)
c.Write(respBytes)

View File

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

View File

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