diff options
author | Wolfy-J <[email protected]> | 2018-05-31 14:10:59 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-05-31 14:10:59 +0300 |
commit | 48f4f7a39a2336be24cc74b4116c02cc941dbd9a (patch) | |
tree | 3de1d379e43fe0772fb699852eac08ded6bbe644 /http/response.go | |
parent | ec2af29c17402145547699e719902d0f3f2ec8ec (diff) |
http support
Diffstat (limited to 'http/response.go')
-rw-r--r-- | http/response.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/http/response.go b/http/response.go new file mode 100644 index 00000000..6a094bf3 --- /dev/null +++ b/http/response.go @@ -0,0 +1,34 @@ +package http + +import ( + "net/http" + "github.com/sirupsen/logrus" +) + +type Response struct { + Status int `json:"status"` + Headers map[string][]string `json:"headers"` +} + +func (r *Response) Write(w http.ResponseWriter) { + push := make([]string, 0) + for k, v := range r.Headers { + for _, h := range v { + if k == "http2-push" { + push = append(push, h) + } else { + w.Header().Add(k, h) + } + } + } + + if p, ok := w.(http.Pusher); ok { + logrus.Info("PUSH SUPPORTED") + for _, f := range push { + logrus.Info("pushing HTTP2 file ", f) + p.Push(f, nil) + } + } + + w.WriteHeader(r.Status) +} |