remove unnecessary code

This commit is contained in:
yanghuiwen 2021-01-06 12:13:30 +08:00
parent b4400d94df
commit eb64006fcb

View File

@ -30,8 +30,8 @@ type response struct {
} }
func (r *response) Preflight(ctx iris.Context) error { func (r *response) Preflight(ctx iris.Context) error {
if (*r).ID > 0 { if r.ID > 0 {
(*r).Timestamp = time.Now().Unix() r.Timestamp = time.Now().Unix()
} }
if code := r.Code; code > 0 { if code := r.Code; code > 0 {
@ -46,7 +46,7 @@ func (r *response) Preflight(ctx iris.Context) error {
Code: code, Code: code,
/* use any r.Data as the template data /* use any r.Data as the template data
OR the whole "response" as its data. */ OR the whole "response" as its data. */
Data: *r, Data: r,
/* automatically pick the template per error (just for the sake of the example) */ /* automatically pick the template per error (just for the sake of the example) */
Name: fmt.Sprintf("%d", code), Name: fmt.Sprintf("%d", code),
}.Dispatch(ctx) }.Dispatch(ctx)
@ -54,7 +54,7 @@ func (r *response) Preflight(ctx iris.Context) error {
return iris.ErrStopExecution return iris.ErrStopExecution
} }
ctx.StatusCode((*r).Code) ctx.StatusCode(r.Code)
} }
return nil return nil