Blame view

go/src/themaru/vendor/github.com/gin-gonic/gin/render/text.go 1.03 KB
476d2547e   김태훈   태마루 시스템 설정 / 업데이트...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  // 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 (
  	"fmt"
  	"io"
  	"net/http"
  )
  
  // String contains the given interface object slice and its format.
  type String struct {
  	Format string
  	Data   []interface{}
  }
  
  var plainContentType = []string{"text/plain; charset=utf-8"}
  
  // Render (String) writes data with custom ContentType.
  func (r String) Render(w http.ResponseWriter) error {
  	return WriteString(w, r.Format, r.Data)
  }
  
  // WriteContentType (String) writes Plain ContentType.
  func (r String) WriteContentType(w http.ResponseWriter) {
  	writeContentType(w, plainContentType)
  }
  
  // WriteString writes data according to its format and write custom ContentType.
  func WriteString(w http.ResponseWriter, format string, data []interface{}) (err error) {
  	writeContentType(w, plainContentType)
  	if len(data) > 0 {
  		_, err = fmt.Fprintf(w, format, data...)
  		return
  	}
  	_, err = io.WriteString(w, format)
  	return
  }