Skip to content

Unable to c.NoContent inside HTTPErrorHandler #424

@andreyvital

Description

@andreyvital

Well, this code was working before:

func echoHTTPErrorHandler(err error, c echo.Context) {
    switch err.(type) {
    case *echo.HTTPError:
        e := err.(*echo.HTTPError)

        log.Printf("%d %s", e.Code, e.Message)

        c.Response().WriteHeader(e.Code)
    default:
        log.Println(err)
    }
}

And even after changing c.Response().WriteHeader(e.Code) to c.NoContent(e.Code) which is a synthesized version as now I have access to echo.Context it still doesn't work.

The problem:

2016/03/19 19:40:14 404 Not Found
2016/03/19 19:40:14 http: multiple response.WriteHeader calls

And I get HTTP/1.1 200 OK instead of 404 Not Found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions