I just played with a google GO official example Writing Web Applications I tried to add a functionality to delete pages and it has not worked. The reason is that if you pass "/delete/"
as a parameter to http.HandleFunc()
function you get always 404 Page not found. Any other "foobar"
string works as expected.
Simplified code:
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", r.URL.Path)
}
func main() {
http.HandleFunc("/hello/", handler)
//http.HandleFunc("/delete/", handler)
http.ListenAndServe(":8080", nil)
}
Steps to reproduce:
- Compile and call
http://localhost:8080/hello/world
from a browser - Output is
/hello/world
- Now comment
http.HandleFunc("/hello/", handler)
and uncommenthttp.HandleFunc("/delete/", handler)
- Compile and call
http://localhost:8080/delete/world
from a browser - Result is
404 page not found
, expected/delete/world
Question:
Is there any special meaning for "/delete/"
pattern? Is there any technical reason for that or is it just a bug?