Skip to content

http.Handle("/", ...) effectively hijacks pages from being not found (due to trailing "/" in the "pattern") #231

@gopherbot

Description

@gopherbot

by montsamu:

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. http.Handle("/", SomeFunc);
2. visit your web server "/notfound"

What is the expected output? What do you see instead?

Expected output is a 404 page; instead the SomeFunc result behaviour occurs 
because "/" is treated as any other pattern instead of allowing an exact 
match only.

What is your $GOOS?  $GOARCH?

sam@sol:~/go$ set | grep GO
GOARCH=amd64
GOOS=linux
GOROOT=/home/sam/go

Which revision are you sync'ed to?  (hg log -l 1)

sam@sol:~/go$ hg log -l 1
changeset:   4068:57c2810ca63f
tag:         tip
user:        Robert Griesemer <gri@golang.org>
date:        Mon Nov 16 08:58:55 2009 -0800
summary:     - Clarify that struct composite literal keys are field names 
not selectors.

Please provide any additional information below.

I am requesting a means of specifying an exact pattern only in a ServeMux, 
specifically to handle the the case of "/" instead of the default pattern 
behavior for patterns ending in a slash. There may be such a behavior but 
it is not documented at: http://golang.org/pkg/http/#tmp_272

(Some examples might be: allow "/$" to mean an exact path match only 
instead of the default sub-pattern handling.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions