Skip to content

Feature Request: Conveniece Method for Allowing HEAD Requests #654

Description

@jonnyreeves

Description

HEAD
Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.

I would like to be able to configure echo in such a way that every time I register a Get handler, a Head handler is automatically added, ie:

server.go

e := echo.New()
e.Get("/", func(c echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!")
})
e.Run(standard.New(":1323"))

curl command

# make a HEAD request
jonny$ curl -I http://localhost:1323/
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Sat, 10 Sep 2016 13:12:36 GMT

# make a GET request
jonny$ curl http://localhost:1323/
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Sat, 10 Sep 2016 13:12:36 GMT

Hello, World!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions