1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-04 02:37:14 +00:00

.NET Core vs Iris MVC vs Iris (classic API with Handlers)

No need to format using Writef on benchmarks for a simple string value without dynamic text, just use the WriteString which is the correct function for these apps.


Former-commit-id: 896ec514570d533d8da91af3ad199fc4f823fe74
This commit is contained in:
kataras
2017-08-19 07:11:30 +03:00
parent ca4c66d5b4
commit 151e38d5c8
8 changed files with 32 additions and 24 deletions

View File

@@ -115,13 +115,22 @@ func (w *GzipResponseWriter) Write(contents []byte) (int, error) {
//
// Returns the number of bytes written and any write error encountered.
func (w *GzipResponseWriter) Writef(format string, a ...interface{}) (n int, err error) {
return fmt.Fprintf(w, format, a...)
n, err = fmt.Fprintf(w, format, a...)
if err == nil {
w.ResponseWriter.Header().Set(contentTextHeaderValue, "text/plain")
}
return
}
// WriteString prepares the string data write to the gzip writer and finally to its
// underline response writer, returns the uncompressed len(contents).
func (w *GzipResponseWriter) WriteString(s string) (int, error) {
return w.Write([]byte(s))
func (w *GzipResponseWriter) WriteString(s string) (n int, err error) {
n, err = w.Write([]byte(s))
if err == nil {
w.ResponseWriter.Header().Set(contentTextHeaderValue, "text/plain")
}
return
}
// WriteNow compresses and writes that data to the underline response writer,