diff --git a/benchmarks_test.go b/benchmarks_test.go
index 141d2ac8..95349b73 100644
--- a/benchmarks_test.go
+++ b/benchmarks_test.go
@@ -2,7 +2,7 @@ package gin
import (
"bytes"
- "encoding/json"
+ "html/template"
"net/http"
"net/http/httptest"
"testing"
@@ -63,13 +63,28 @@ func BenchmarkOneRouteJSON(B *testing.B) {
"status": "ok",
}
router.GET("/json", func(c *Context) {
- //c.JSON(200, data)
- c.Writer.WriteHeader(200)
- json.NewEncoder(c.Writer).Encode(data)
+ c.JSON(200, data)
})
runRequest(B, router, "GET", "/json")
}
+var htmlContentType = []string{"text/html; charset=utf-8"}
+
+func BenchmarkOneRouteHTML(B *testing.B) {
+ router := New()
+ t := template.Must(template.New("index").Parse(`
+
{{.}}
`))
+ router.SetHTMLTemplate(t)
+
+ router.GET("/html", func(c *Context) {
+ //c.Writer.Header()["Content-Type"] = htmlContentType
+ //t.ExecuteTemplate(c.Writer, "index", "hola")
+
+ c.HTML(200, "index", "hola")
+ })
+ runRequest(B, router, "GET", "/html")
+}
+
func BenchmarkOneRouteString(B *testing.B) {
router := New()
router.GET("/text", func(c *Context) {
diff --git a/routergroup.go b/routergroup.go
index 74dc82f0..de40d17e 100644
--- a/routergroup.go
+++ b/routergroup.go
@@ -127,11 +127,11 @@ func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem) {
panic("URL parameters can not be used when serving a static folder")
}
handler := group.createStaticHandler(relativePath, fs)
- relativePath = path.Join(relativePath, "/*filepath")
+ urlPattern := path.Join(relativePath, "/*filepath")
// Register GET and HEAD handlers
- group.GET(relativePath, handler)
- group.HEAD(relativePath, handler)
+ group.GET(urlPattern, handler)
+ group.HEAD(urlPattern, handler)
}
func (group *RouterGroup) createStaticHandler(relativePath string, fs http.FileSystem) HandlerFunc {