julienschmidt / httprouter

A high performance HTTP request router that scales well

Home Page:https://pkg.go.dev/github.com/julienschmidt/httprouter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: '/hello/:name' in new path '/hello/:name' conflicts with existing wildcar

Nemnon opened this issue · comments

`package main

import (
"fmt"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
)

func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}

func main() {
router := httprouter.New()
router.ServeFiles("/*filepath", http.Dir("./templates"))
router.GET("/hello/:name", Hello)
log.Fatal(http.ListenAndServe(":8080", router))
}`

panic: '/hello/:name' in new path '/hello/:name' conflicts with existing wildcard '/*filepath' in existing prefix '/*filepath'