mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +01:00
fix response.timestamp not appear in correct request.
This commit is contained in:
parent
3e6fd79906
commit
b4400d94df
|
@ -29,9 +29,9 @@ type response struct {
|
||||||
Timestamp int64 `json:"timestamp,omitempty"`
|
Timestamp int64 `json:"timestamp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
@ -64,15 +64,15 @@ type user struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controller) GetBy(userid uint64) response {
|
func (c *controller) GetBy(userid uint64) *response {
|
||||||
if userid != 1 {
|
if userid != 1 {
|
||||||
return response{
|
return &response{
|
||||||
Code: iris.StatusNotFound,
|
Code: iris.StatusNotFound,
|
||||||
Message: "User Not Found",
|
Message: "User Not Found",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response{
|
return &response{
|
||||||
ID: userid,
|
ID: userid,
|
||||||
Data: user{ID: userid},
|
Data: user{ID: userid},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user