api

package
v0.0.0-...-67235b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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

func MattermostAuthorizationRequired(next http.Handler) http.Handler

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

func NewHandler(pluginAPI *pluginapi.Client, log bot.Logger) *Handler

NewHandler constructs a new handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL