404 not found performance improvements
benchmark old ns/op new ns/op delta Benchmark404 737 249 -66.21% Benchmark404Many 2330 454 -80.52% benchmark old allocs new allocs delta Benchmark404 3 0 -100.00% Benchmark404Many 10 0 -100.00% benchmark old bytes new bytes delta Benchmark404 115 68 -40.87% Benchmark404Many 235 57 -75.74%
This commit is contained in:
@ -13,7 +13,7 @@ type Data struct {
|
||||
|
||||
func (r Data) Write(w http.ResponseWriter) error {
|
||||
if len(r.ContentType) > 0 {
|
||||
w.Header().Set("Content-Type", r.ContentType)
|
||||
w.Header()["Content-Type"] = []string{r.ContentType}
|
||||
}
|
||||
w.Write(r.Data)
|
||||
return nil
|
||||
|
@ -6,6 +6,7 @@ package render
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@ -24,7 +25,7 @@ func (r String) Write(w http.ResponseWriter) error {
|
||||
if len(r.Data) > 0 {
|
||||
fmt.Fprintf(w, r.Format, r.Data...)
|
||||
} else {
|
||||
w.Write([]byte(r.Format))
|
||||
io.WriteString(w, r.Format)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user