Home / File/ yaml.go — gin Source File

yaml.go — gin Source File

Architecture documentation for yaml.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go 1 imports 1 classes

Entity Profile

Dependency Diagram

graph LR
  ea768e6a_769f_120b_34fc_1a9842421860["yaml.go"]
  08248871_dc00_f330_15ef_4a0fbf2bafbb["http"]
  ea768e6a_769f_120b_34fc_1a9842421860 --> 08248871_dc00_f330_15ef_4a0fbf2bafbb
  style ea768e6a_769f_120b_34fc_1a9842421860 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// 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"

	"github.com/goccy/go-yaml"
)

// YAML contains the given interface object.
type YAML struct {
	Data any
}

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

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

	bytes, err := yaml.Marshal(r.Data)
	if err != nil {
		return err
	}

	_, err = w.Write(bytes)
	return err
}

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

Classes

Types

Dependencies

  • http

Frequently Asked Questions

What does yaml.go do?
yaml.go is a source file in the gin codebase, written in go.
What does yaml.go depend on?
yaml.go imports 1 module(s): http.
Where is yaml.go in the architecture?
yaml.go is located at render/yaml.go (directory: render).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free