From 836cb84fdcabd74b8f4739ea238bfd85e9af4374 Mon Sep 17 00:00:00 2001 From: Carl Jackson Date: Sun, 23 Mar 2014 12:50:04 -0700 Subject: [PATCH] Automatic HEAD support for GET handlers --- web/router.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/router.go b/web/router.go index f7b9de4..02315da 100644 --- a/web/router.go +++ b/web/router.go @@ -223,8 +223,13 @@ func (m *router) Delete(pattern interface{}, handler interface{}) { // Dispatch to the given handler when the pattern matches and the HTTP method is // GET. See the documentation for type Mux for a description of what types are // accepted for pattern and handler. +// +// All GET handlers also transparently serve HEAD requests, since net/http will +// take care of all the fiddly bits for you. If you wish to provide an alternate +// implementation of HEAD, you should add a handler explicitly and place it +// above your GET handler. func (m *router) Get(pattern interface{}, handler interface{}) { - m.handleUntyped(pattern, mGET, handler) + m.handleUntyped(pattern, mGET|mHEAD, handler) } // Dispatch to the given handler when the pattern matches and the HTTP method is