podman
1// Copyright 2022 Gin Core Team. 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
5package render6
7import (8"net/http"9
10"github.com/pelletier/go-toml/v2"11)
12
13// TOML contains the given interface object.
14type TOML struct {15Data any
16}
17
18var TOMLContentType = []string{"application/toml; charset=utf-8"}19
20// Render (TOML) marshals the given interface object and writes data with custom ContentType.
21func (r TOML) Render(w http.ResponseWriter) error {22r.WriteContentType(w)23
24bytes, err := toml.Marshal(r.Data)25if err != nil {26return err27}28
29_, err = w.Write(bytes)30return err31}
32
33// WriteContentType (TOML) writes TOML ContentType for response.
34func (r TOML) WriteContentType(w http.ResponseWriter) {35writeContentType(w, TOMLContentType)36}
37