Skip to content

Commit ec5a8b4

Browse files
committed
add httprouter example code and stub.go
1 parent ac3cb7f commit ec5a8b4

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net/http"
7+
8+
"github.com/julienschmidt/httprouter"
9+
)
10+
11+
func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
12+
fmt.Fprint(w, "Welcome!\n")
13+
}
14+
15+
func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
16+
fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
17+
}
18+
19+
func badHTTPRouter() {
20+
router := httprouter.New()
21+
router.GET("/test/*test", Index)
22+
router.GET("/hello/:name", Hello)
23+
24+
log.Fatal(http.ListenAndServe(":8082", router))
25+
}

go/ql/test/experimental/CWE-525/vendor/github.com/julienschmidt/httprouter/stub.go

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)