podman

Форк
0
36 строк · 815.0 Байт
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 (
8
	"net/http"
9

10
	"gopkg.in/yaml.v3"
11
)
12

13
// YAML contains the given interface object.
14
type YAML struct {
15
	Data any
16
}
17

18
var yamlContentType = []string{"application/x-yaml; charset=utf-8"}
19

20
// Render (YAML) marshals the given interface object and writes data with custom ContentType.
21
func (r YAML) Render(w http.ResponseWriter) error {
22
	r.WriteContentType(w)
23

24
	bytes, err := yaml.Marshal(r.Data)
25
	if err != nil {
26
		return err
27
	}
28

29
	_, err = w.Write(bytes)
30
	return err
31
}
32

33
// WriteContentType (YAML) writes YAML ContentType for response.
34
func (r YAML) WriteContentType(w http.ResponseWriter) {
35
	writeContentType(w, yamlContentType)
36
}
37

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.