Documentation ¶
Index ¶
- Constants
- Variables
- func FilterOwner(value map[string]OwnableItem, owner string) map[string]OwnableItem
- func ProvideHandlers() fx.Option
- func SanitizeError(err error) error
- func Sha256HexDigest(message string) string
- type BadRequestErr
- type ForbiddenRequestErr
- type GetAllItemsOperationErr
- type GetLoggerFunc
- type Handler
- type InternalError
- type ItemOperationError
- type KeyItemPairRequest
- type KeyNotFoundError
- type OwnableItem
- type S
- type SanitizedError
- type UserInputValidationConfig
Constants ¶
const ( BucketFormatRegexSource = "^[0-9a-z][0-9a-z-]{1,61}[0-9a-z]$" OwnerFormatRegexSource = "^.{10,60}$" )
default input field validation regular expressions. Note: these values are configurable so please check the argus.yaml file if you're interested.
const ( // TypeLabel is for labeling metrics; if there is a single metric for // successful queries, the typeLabel and corresponding type can be used // when incrementing the metric. TypeLabel = "type" InsertType = "insert" DeleteType = "delete" ReadType = "read" PingType = "ping" )
const ( ItemOwnerHeaderKey = "X-Midt-Owner" XmidtErrorHeaderKey = "X-Midt-Error" )
Request and Response Headers.
const ElevatedAccessLevel = 1
ElevatedAccessLevel is the bascule attribute value found in requests that should be granted priviledged access to operations.
const IDFormatRegexSource = "^[0-9a-f]{64}$"
IDFormatRegexSource helps validate the ID on incoming requests.
Variables ¶
var ( ErrItemNotFound = errors.New("Item at resource path not found") ErrJSONDecode = errors.New("Error decoding JSON data from DB") ErrJSONEncode = errors.New("Error encoding JSON data to send to DB") ErrQueryExecution = errors.New("Error occurred during DB query execution") )
Sentinel internal errors.
var ( ErrHTTPItemNotFound = &erraux.Error{Err: errors.New("Item not found"), Code: http.StatusNotFound} ErrHTTPOpFailed = &erraux.Error{Err: errors.New("DB operation failed"), Code: http.StatusInternalServerError} )
Sentinel errors to be used by the HTTP response error encoder.
var ErrCasting = errors.New("casting error due to middleware wiring mistake")
ErrCasting indicates there was (most likely) a middleware wiring mistake with the go-kit style encoders/decoders.
Functions ¶
func FilterOwner ¶ added in v0.2.0
func FilterOwner(value map[string]OwnableItem, owner string) map[string]OwnableItem
func ProvideHandlers ¶ added in v0.3.10
ProvideHandlers fetches all dependencies and builds the four main handlers for this store.
func SanitizeError ¶ added in v0.3.13
SanitizeError should be used by DB implementations to prevent exposing internal error data in HTTP responses. This method maps an internal error to their sanitized version which contains HTTP response information like code and debug header values. DB implementations should implement their own versions of this function when they need to look at implementation-specific errors to perform the mapping.
func Sha256HexDigest ¶ added in v0.3.10
Sha256HexDigest returns the SHA-256 hex digest of the given input.
Types ¶
type BadRequestErr ¶ added in v0.3.6
type BadRequestErr struct {
Message string
}
func (BadRequestErr) Error ¶ added in v0.3.6
func (bre BadRequestErr) Error() string
func (BadRequestErr) SanitizedError ¶ added in v0.6.0
func (bre BadRequestErr) SanitizedError() string
func (BadRequestErr) StatusCode ¶ added in v0.3.6
func (bre BadRequestErr) StatusCode() int
type ForbiddenRequestErr ¶ added in v0.3.8
type ForbiddenRequestErr struct {
Message string
}
func (ForbiddenRequestErr) Error ¶ added in v0.3.8
func (f ForbiddenRequestErr) Error() string
func (ForbiddenRequestErr) StatusCode ¶ added in v0.3.8
func (f ForbiddenRequestErr) StatusCode() int
type GetAllItemsOperationErr ¶ added in v0.3.13
GetAllItemsOperationError is the ItemOperation counterpart for the getAllItems operation which applies to a group of items.
func (GetAllItemsOperationErr) Error ¶ added in v0.3.13
func (e GetAllItemsOperationErr) Error() string
func (GetAllItemsOperationErr) Unwrap ¶ added in v0.3.13
func (e GetAllItemsOperationErr) Unwrap() error
type GetLoggerFunc ¶ added in v0.6.0
GetLoggerFunc is the function used to get a request-specific logger from its context.
type InternalError ¶ added in v0.2.1
type InternalError struct { Reason interface{} Retryable bool }
func (InternalError) Error ¶ added in v0.2.1
func (ie InternalError) Error() string
func (InternalError) StatusCode ¶ added in v0.2.1
func (ie InternalError) StatusCode() int
type ItemOperationError ¶ added in v0.3.13
ItemOperationError is a simple error wrapper for DB operations that apply to specific items. It provides a formatted message with context around the error.
func (ItemOperationError) Error ¶ added in v0.3.13
func (e ItemOperationError) Error() string
func (ItemOperationError) Unwrap ¶ added in v0.3.13
func (e ItemOperationError) Unwrap() error
type KeyItemPairRequest ¶ added in v0.2.0
type KeyItemPairRequest struct { model.Key OwnableItem Method string }
type KeyNotFoundError ¶
func (KeyNotFoundError) Error ¶
func (knfe KeyNotFoundError) Error() string
func (KeyNotFoundError) StatusCode ¶
func (knfe KeyNotFoundError) StatusCode() int
type OwnableItem ¶ added in v0.2.0
type S ¶
type S interface { Push(key model.Key, item OwnableItem) error Get(key model.Key) (OwnableItem, error) Delete(key model.Key) (OwnableItem, error) GetAll(bucket string) (map[string]OwnableItem, error) }
type SanitizedError ¶ added in v0.3.13
type SanitizedError struct { // Err contains the raw error explaining the cause of the // failure event. Err error // ErrHTTP should contain some filtered version // of Err that can be safely used across API boundaries. // Two use cases include: hiding sensitive error data and // translating errors to better explain error events to API consumers. ErrHTTP *erraux.Error }
func (SanitizedError) Error ¶ added in v0.3.13
func (s SanitizedError) Error() string
func (SanitizedError) Headers ¶ added in v0.3.13
func (s SanitizedError) Headers() http.Header
func (SanitizedError) SanitizedError ¶ added in v0.3.13
func (s SanitizedError) SanitizedError() string
func (SanitizedError) StatusCode ¶ added in v0.3.13
func (s SanitizedError) StatusCode() int
func (SanitizedError) Unwrap ¶ added in v0.3.13
func (s SanitizedError) Unwrap() error