yaml.go
This file
Path
render/yaml.go
36 lines · 821 bytes · Go
Last changed by
chroe: migrate yaml package to github.com/goccy/go-yaml (#4272)M. Ilham Surya Pratamabefore adoptioncf47752
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–9why, 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 render67import (8 "net/http"9chroe: migrate yaml package to github.com/goccy/go-yaml (#4272)M. Ilham Surya Pratamabefore adoptioncf47752
line 10why, one step back10 "github.com/goccy/go-yaml"chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 11–36why, one step back11)1213// YAML contains the given interface object.14type YAML struct {15 Data any16}1718var yamlContentType = []string{"application/yaml; charset=utf-8"}1920// Render (YAML) marshals the given interface object and writes data with custom ContentType.21func (r YAML) Render(w http.ResponseWriter) error {22 r.WriteContentType(w)2324 bytes, err := yaml.Marshal(r.Data)25 if err != nil {26 return err27 }2829 _, err = w.Write(bytes)30 return err31}3233// WriteContentType (YAML) writes YAML ContentType for response.34func (r YAML) WriteContentType(w http.ResponseWriter) {35 writeContentType(w, yamlContentType)36}