forked from evergreen-ci/gimlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandling_html.go
More file actions
32 lines (27 loc) · 1.01 KB
/
handling_html.go
File metadata and controls
32 lines (27 loc) · 1.01 KB
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
package gimlet
import (
"net/http"
)
// WriteHTMLResponse writes an HTML response with the specified error code.
func WriteHTMLResponse(w http.ResponseWriter, code int, data interface{}) {
writeResponse(HTML, w, code, data)
}
// WriteHTML writes the data, converted to text as possible, to the
// response body as HTML with a successful status code.
func WriteHTML(w http.ResponseWriter, data interface{}) {
// 200
WriteHTMLResponse(w, http.StatusOK, data)
}
// WriteHTMLError write the data, converted to text as possible, to
// the response body as HTML with a bad-request (e.g. 400) response code.
func WriteHTMLError(w http.ResponseWriter, data interface{}) {
// 400
WriteHTMLResponse(w, http.StatusBadRequest, data)
}
// WriteHTMLInternalError write the data, converted to text as possible, to
// the response body as HTML with an internal server error (e.g. 500)
// response code.
func WriteHTMLInternalError(w http.ResponseWriter, data interface{}) {
// 500
WriteHTMLResponse(w, http.StatusInternalServerError, data)
}