Documentation
¶
Index ¶
- func HandleErrorWithCode(logger bot.Logger, w http.ResponseWriter, code int, publicErrorMsg string, ...)
- func MattermostAuthorizationRequired(next http.Handler) http.Handler
- func ReturnJSON(w http.ResponseWriter, pointerToObject interface{}, httpStatus int)
- type ErrorHandler
- type Handler
- type WikiDocHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleErrorWithCode ¶
func HandleErrorWithCode(logger bot.Logger, w http.ResponseWriter, code int, publicErrorMsg string, internalErr error)
HandleErrorWithCode logs the internal error and sends the public facing error message as JSON in a response with the provided code.
func MattermostAuthorizationRequired ¶
MattermostAuthorizationRequired checks if request is authorized.
func ReturnJSON ¶
func ReturnJSON(w http.ResponseWriter, pointerToObject interface{}, httpStatus int)
ReturnJSON writes the given pointerToObject as json with the provided httpStatus
Types ¶
type ErrorHandler ¶
type ErrorHandler struct {
// contains filtered or unexported fields
}
func (*ErrorHandler) HandleError ¶
func (h *ErrorHandler) HandleError(w http.ResponseWriter, internalErr error)
HandleError logs the internal error and sends a generic error as JSON in a 500 response.
func (*ErrorHandler) HandleErrorWithCode ¶
func (h *ErrorHandler) HandleErrorWithCode(w http.ResponseWriter, code int, publicErrorMsg string, internalErr error)
HandleErrorWithCode logs the internal error and sends the public facing error message as JSON in a response with the provided code.
func (*ErrorHandler) PermissionsCheck ¶
func (h *ErrorHandler) PermissionsCheck(w http.ResponseWriter, checkOutput error) bool
PermissionsCheck handles the output of a permisions check Automatically does the proper error handling. Returns true if the check passed and false on failure. Correct use is: if !h.PermissionsCheck(w, check) { return }
type Handler ¶
type Handler struct {
*ErrorHandler
APIRouter *mux.Router
// contains filtered or unexported fields
}
Handler Root API handler.
func NewHandler ¶
NewHandler constructs a new handler.
type WikiDocHandler ¶
type WikiDocHandler struct {
*ErrorHandler
// contains filtered or unexported fields
}
WikiDocHandler is the API handler.
func NewWikiDocHandler ¶
func NewWikiDocHandler( router *mux.Router, wikiDocService app.WikiDocService, permissions *app.PermissionsService, api *pluginapi.Client, log bot.Logger, ) *WikiDocHandler
NewWikiDocHandler Creates a new Plugin API handler.