generated from mattermost/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 29
/
error.go
38 lines (32 loc) · 1003 Bytes
/
error.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
package main
import (
"net/http"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-plugin-apps/apps"
"github.com/mattermost/mattermost-plugin-apps/utils/httputils"
)
func initHTTPError(r *mux.Router) {
handleCall(r, ErrorDefault, handleError("Error"))
handleCall(r, ErrorEmpty, handleError(""))
handleCall(r, ErrorMarkdownForm, handleErrorMarkdownForm)
handleCall(r, ErrorMarkdownFormMissingField, handleErrorMarkdownFormMissingField)
r.HandleFunc(Error404, func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "TEST ERROR 404 ignored", http.StatusNotFound)
})
r.HandleFunc(Error500, func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "TEST ERROR 500", http.StatusInternalServerError)
})
r.HandleFunc(InvalidUnknownType, httputils.DoHandleJSON(apps.CallResponse{
Type: "unknown",
}))
r.HandleFunc(InvalidHTML, httputils.DoHandleData("text/html", []byte(`
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>HTML example</p>
</body>
</html>
`)))
}