当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
2 Star 19 Fork 0

仓库镜像 / gin-gonic-gin
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
yaml.go 611 Bytes
一键复制 编辑 原始数据 按行查看 历史
Javier Provecho Fernandez 提交于 2017-01-09 16:24 . Fix #198 (#781)
// 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 render
import (
"net/http"
"gopkg.in/yaml.v2"
)
type YAML struct {
Data interface{}
}
var yamlContentType = []string{"application/x-yaml; charset=utf-8"}
func (r YAML) Render(w http.ResponseWriter) error {
r.WriteContentType(w)
bytes, err := yaml.Marshal(r.Data)
if err != nil {
return err
}
w.Write(bytes)
return nil
}
func (r YAML) WriteContentType(w http.ResponseWriter) {
writeContentType(w, yamlContentType)
}
Go
1
https://gitee.com/github-image/gin-gonic-gin.git
git@gitee.com:github-image/gin-gonic-gin.git
github-image
gin-gonic-gin
gin-gonic-gin
v1.3.0

搜索帮助