mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
Rename response attributes
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user