github.com/hellobchain/third_party@v0.0.0-20230331131523-deb0478a2e52/gin/render/data.go (about) 1 // Copyright 2014 Manu Martinez-Almeida. All rights reserved. 2 // Use of this source code is governed by a MIT style 3 // license that can be found in the LICENSE file. 4 5 package render 6 7 import "github.com/hellobchain/newcryptosm/http" 8 9 // Data contains ContentType and bytes data. 10 type Data struct { 11 ContentType string 12 Data []byte 13 } 14 15 // Render (Data) writes data with custom ContentType. 16 func (r Data) Render(w http.ResponseWriter) (err error) { 17 r.WriteContentType(w) 18 _, err = w.Write(r.Data) 19 return 20 } 21 22 // WriteContentType (Data) writes custom ContentType. 23 func (r Data) WriteContentType(w http.ResponseWriter) { 24 writeContentType(w, []string{r.ContentType}) 25 }