data.go
This file
Path
render/data.go
31 lines · 742 bytes · Go
Last changed by
fix(render): write content length in Data.Render (#4206)Denis Galeevbefore adoption5c00df8
History of this fileTake it
The walk stopped after 200 commits: lines older than cf32d2d point at it.
chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 1–6why, one step back1// Copyright 2014 Manu Martinez-Almeida. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package render6fix(render): write content length in Data.Render (#4206)Denis Galeevbefore adoption5c00df8
lines 7–10why, one step back7import (8 "net/http"9 "strconv"10)chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 11–20why, one step back1112// Data contains ContentType and bytes data.13type Data struct {14 ContentType string15 Data []byte16}1718// Render (Data) writes data with custom ContentType.19func (r Data) Render(w http.ResponseWriter) (err error) {20 r.WriteContentType(w)fix(render): write content length in Data.Render (#4206)Denis Galeevbefore adoption5c00df8
lines 21–23why, one step back21 if len(r.Data) > 0 {22 w.Header().Set("Content-Length", strconv.Itoa(len(r.Data)))23 }chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 24–31why, one step back24 _, err = w.Write(r.Data)25 return26}2728// WriteContentType (Data) writes custom ContentType.29func (r Data) WriteContentType(w http.ResponseWriter) {30 writeContentType(w, []string{r.ContentType})31}