Documentation ¶
Overview ¶
Package webapp implements a simple http web server to visualize detection results and to manage alert rules.
Index ¶
- Variables
- func Init(c *config.Config, d *storage.DB)
- func Logger(handler http.Handler) http.Handler
- func RequestBind(r *http.Request, v interface{}) error
- func ResponseError(w http.ResponseWriter, err *WebError) error
- func ResponseJSON(w http.ResponseWriter, code int, v interface{}) error
- func ResponseJSONOK(w http.ResponseWriter, v interface{}) error
- func Start(c *config.Config, d *storage.DB, f *filter.Filter)
- type WebError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Common ErrBadRequest = NewWebError(http.StatusBadRequest, "Bad request") ErrNotNull = NewWebError(http.StatusBadRequest, "Null value") ErrPrimaryKey = NewWebError(http.StatusForbidden, "Primarykey voilated") ErrUnique = NewWebError(http.StatusForbidden, "Value should be unique") ErrNotFound = NewWebError(http.StatusNotFound, "Not found") // Project ErrProjectID = NewWebError(http.StatusBadRequest, "Bad project id") ErrProjectNotFound = NewWebError(http.StatusNotFound, "Project not found") ErrDuplicateProjectName = NewWebError(http.StatusForbidden, "Duplicate project name") ErrDuplicateProjectUser = NewWebError(http.StatusForbidden, "Duplicate user to project") ErrProjectUniversalUser = NewWebError(http.StatusForbidden, "Cannot add universal user to project") ErrProjectUniversalWebHook = NewWebError(http.StatusForbidden, "Cannot add universal webhook to project") ErrDuplicateProjectWebHook = NewWebError(http.StatusForbidden, "Duplicate webhook to project") // User ErrUserID = NewWebError(http.StatusBadRequest, "Bad user id") ErrUserNotFound = NewWebError(http.StatusNotFound, "User not found") ErrDuplicateUserName = NewWebError(http.StatusForbidden, "Duplicate user name") // WebHook ErrWebHookID = NewWebError(http.StatusBadRequest, "Bad webhook id") ErrWebHookNotFound = NewWebError(http.StatusNotFound, "WebHook not found") ErrDuplicateWebHookName = NewWebError(http.StatusForbidden, "Duplicate webhook name") // Rule ErrRuleID = NewWebError(http.StatusBadRequest, "Bad rule id") ErrDuplicateRulePattern = NewWebError(http.StatusForbidden, "Duplicate rule pattern") ErrRuleNotFound = NewWebError(http.StatusNotFound, "Rule not found") ErrRuleNoCondition = NewWebError(http.StatusBadRequest, "No condition specified") ErrRuleNoComment = NewWebError(http.StatusBadRequest, "No rule comment") ErrRuleCommentNotValid = NewWebError(http.StatusBadRequest, "Rule comment is not valid, empty?") ErrRuleUpdateFailed = NewWebError(http.StatusBadRequest, "Failed to update rule") // Metric ErrMetricNotFound = NewWebError(http.StatusNotFound, "Metric not found") // Event ErrEventPast = NewWebError(http.StatusBadRequest, "Bad event time past") ErrEventTimeRange = NewWebError(http.StatusBadRequest, "Bad event time range") )
Errors
Functions ¶
func RequestBind ¶
RequestBind binds request data into value.
func ResponseError ¶
func ResponseError(w http.ResponseWriter, err *WebError) error
ResponseError writes WebError as response.
func ResponseJSON ¶
func ResponseJSON(w http.ResponseWriter, code int, v interface{}) error
ResponseJSON encodes value to json and write as response.
func ResponseJSONOK ¶
func ResponseJSONOK(w http.ResponseWriter, v interface{}) error
ResponseJSONOK writes ok response.
Types ¶
type WebError ¶
type WebError struct { // HTTP status code Code int `json:"code"` // Message Msg string `json:"msg"` }
WebError is errors for web operations.
func NewUnexceptedWebError ¶
NewUnexceptedWebError returns an unexcepted WebError.
func NewValidationWebError ¶ added in v0.0.7
NewValidationWebError creates a validation WebError from error.
func NewWebError ¶
NewWebError creates a WebError.
Click to show internal directories.
Click to hide internal directories.