-
Notifications
You must be signed in to change notification settings - Fork 7
/
api.go
82 lines (64 loc) · 1.86 KB
/
api.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package html
import (
"io"
"net/http"
)
type HtmlWriter interface {
WriteHtml(writer io.Writer)
}
type TableWriter struct {
doHighlighting bool
lastBackground string
writer io.Writer
}
func BenchmarkedHandler(handler func(io.Writer,
*http.Request)) func(http.ResponseWriter, *http.Request) {
return benchmarkedHandler(handler)
}
func HandleFunc(pattern string,
handler func(w http.ResponseWriter, req *http.Request)) {
handleFunc(http.DefaultServeMux, pattern, handler)
}
func RegisterHtmlWriterForPattern(pattern, title string,
htmlWriter HtmlWriter) {
registerHtmlWriterForPattern(pattern, title, htmlWriter)
}
func ServeMuxHandleFunc(serveMux *http.ServeMux, pattern string,
handler func(w http.ResponseWriter, req *http.Request)) {
handleFunc(serveMux, pattern, handler)
}
func SetSecurityHeaders(w http.ResponseWriter) {
setSecurityHeaders(w)
}
func NewTableWriter(writer io.Writer, doHighlighting bool,
columns ...string) (*TableWriter, error) {
return newTableWriter(writer, doHighlighting, columns)
}
func (tw *TableWriter) CloseRow() error {
return tw.closeRow()
}
func (tw *TableWriter) OpenRow(foreground, background string) error {
return tw.openRow(foreground, background)
}
func (tw *TableWriter) WriteData(foreground, data string) error {
return tw.writeData(foreground, data)
}
func (tw *TableWriter) WriteRow(foreground, background string,
columns ...string) error {
return tw.writeRow(foreground, background, columns)
}
func WriteFooter(writer io.Writer) {
writeFooter(writer)
}
func WriteHeader(writer io.Writer) {
writeHeader(writer, nil, false)
}
func WriteHeaderNoGC(writer io.Writer) {
writeHeader(writer, nil, true)
}
func WriteHeaderWithRequest(writer io.Writer, req *http.Request) {
writeHeader(writer, req, false)
}
func WriteHeaderWithRequestNoGC(writer io.Writer, req *http.Request) {
writeHeader(writer, req, true)
}