forked from gin-gonic/gin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
response_writer.go
32 lines (26 loc) · 959 Bytes
/
response_writer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gin
import (
"net/http"
"github.com/chanxuehong/gin/internal/response"
)
// type ResponseWriter interface {
// http.ResponseWriter
// WroteHeader() bool // WroteHeader returns true if header has been written, otherwise false.
// Status() int // Status returns the response status code of the current request.
// Written() int64 // Written returns number of bytes written in body.
// }
type ResponseWriter response.ResponseWriter
type responseWriterArray [32]response.ResponseWriter2
func (cache *responseWriterArray) ResponseWriter2(w http.ResponseWriter) response.ResponseWriter2 {
index := response.Bitmap(w)
resp := cache[index]
if resp == nil {
resp = response.NewResponseWriter2(index)
cache[index] = resp
}
resp.Reset(w)
return resp
}