1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-01-17 17:45:03 +02:00

34 lines
661 B
Go
Raw Normal View History

2015-09-29 18:21:17 -07:00
// 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.
2015-05-22 11:37:40 -07:00
package render
import (
"fmt"
2015-09-29 18:21:17 -07:00
"io"
2015-05-22 11:37:40 -07:00
"net/http"
)
type String struct {
Format string
Data []interface{}
}
2015-09-29 18:21:17 -07:00
var plainContentType = []string{"text/plain; charset=utf-8"}
func (r String) Render(w http.ResponseWriter) error {
WriteString(w, r.Format, r.Data)
return nil
}
func WriteString(w http.ResponseWriter, format string, data []interface{}) {
writeContentType(w, plainContentType)
if len(data) > 0 {
fmt.Fprintf(w, format, data...)
2015-05-22 11:37:40 -07:00
} else {
2015-09-29 18:21:17 -07:00
io.WriteString(w, format)
2015-05-22 11:37:40 -07:00
}
}