1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-22 20:06:21 +02:00
Commit Graph

24 Commits

Author SHA1 Message Date
Rashad Ansari
0406abe066 Add the ability to change the status code using Response beforeFuncs 2020-12-06 18:31:15 +03:30
Takashi Iwamoto
4aebe68f37 Add test for 'func (*Response) After' 2020-04-26 22:09:10 +09:00
Takashi Iwamoto
a8b5de4286
Add test case for Response (#1557) 2020-04-25 11:01:03 -07:00
Noam Y. Tenne
fbb72869b3 Fix for #1334 (#1335)
* echo.context.cjson should encode the JSON before writing the status code #1334 :

`response.Write` automatically sets status to `200` if a response code wasn't committed yet. This is convenient, but it ignores the fact that `response.Status` is a public field that may be set separately/before `response.Write` has been called
A `response.Status` is by default `0`, or `200` if the response was reset, so `response.Write` should fallback to `200` only if a code wasn't set yet.

* echo.context.cjson should encode the JSON before writing the status code #1334 :

Writing the response code before encoding the payload is prone to error.
If JSON encoding fails, the response code is already committed, the server is able to only modify the response body to reflect the error and the user receives an awkward response where the status is successful but the body reports an error.
Instead - set the desired code on `c.response.Status`. If writing eventually takes place, the desired code is committed. If an error occurs, the server can still change the response.
2019-05-23 22:13:57 -07:00
Emir Ribić
c8fd197fa8 Replace http constants with stdlib ones, i.e.: http.MethodGet instead of echo.GET (#1205) 2018-10-14 20:46:58 +05:30
Vishal Rana
ee85b46a05 Changed signature for response before func
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-06-29 10:59:21 -07:00
Vishal Rana
f96c973a25 Fixed #176, closed #831
Signed-off-by: Vishal Rana <vr@labstack.com>
2017-06-28 17:01:48 -07:00
Vishal Rana
f27de9a804 Fixed logging
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-02-04 19:29:49 -08:00
Vishal Rana
2483d2a140 Reset Echo in Response#reset()
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-12-02 08:07:22 -08:00
Vishal Rana
9650c39055 Bumped to v1.3
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-12-01 15:06:18 -08:00
Chase Hutchins
51e07af3f0 adding code coverage 2015-09-13 01:38:22 -07:00
Vishal Rana
b9eec15c01 More test coverage
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-30 15:20:36 -07:00
Vishal Rana
a9e49e2430 Total coverage for middleware
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-30 10:54:55 -07:00
Vishal Rana
9b6c392829 Better tests for response.go
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-29 16:50:46 -07:00
Vishal Rana
76e9b44190 Exposed DefaultHTTPErrorHandler function
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-28 16:50:49 -07:00
Simon Green
87b24d3b7e Response reset size
Set size to 0 when response reset

Prevents logged size accumulating with each request
2015-05-27 21:11:57 -06:00
Vishal Rana
13ac746093 Refactored Echo.HandlerFunc, added WebSocket support.
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-20 14:38:51 -07:00
Vishal Rana
d90395cf2b Using int64 instead of uint64 for response size
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-15 15:24:47 -07:00
Vishal Rana
04cdefb2a6 Fixed #51
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-05-08 11:21:50 -07:00
Vishal Rana
381fbae1ff Default handler now returns error.
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-18 16:47:48 -07:00
Vishal Rana
8f7c55e0ac Refactored response
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-09 11:04:33 -07:00
Vishal Rana
eed30582ae c.Text > c.String
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-06 07:52:00 -07:00
Vishal Rana
c2d29f3895 more coverage
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-04-05 15:30:03 -07:00
Vishal Rana
2e7f411a85 Coverage bumped to 80%
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-03-30 21:06:21 -07:00