Documentation ¶
Index ¶
- Constants
- type AnyValue
- type CloudEvent
- type Error
- func ErrorResponseBadPayload() (response *Error)
- func ErrorResponseBadRequest() (response *Error)
- func ErrorResponseEmptyRequest() (response *Error)
- func ErrorResponseInternalServer() (response *Error)
- func ErrorResponseMissingFieldData() (response *Error)
- func ErrorResponseMissingFieldEventTime() (response *Error)
- func ErrorResponseMissingFieldEventType() (response *Error)
- func ErrorResponseMissingFieldEventTypeVersion() (response *Error)
- func ErrorResponseMissingFieldSourceId() (response *Error)
- func ErrorResponseWrongEventId() (response *Error)
- func ErrorResponseWrongEventTime(err error) (response *Error)
- func ErrorResponseWrongEventType() (response *Error)
- func ErrorResponseWrongEventTypeVersion() (response *Error)
- func ErrorResponseWrongSourceId(sourceIdFromHeader bool) (response *Error)
- func ValidatePublish(r *PublishRequest) *Error
- type ErrorDetail
- type Extensions
- type PublishRequest
- type PublishResponse
- type TraceContext
Constants ¶
View Source
const ( FieldData = "data" FieldEventId = "event-id" FieldEventTime = "event-time" FieldEventType = "event-type" FieldEventTypeVersion = "event-type-version" FieldSourceId = "source-id" FieldTraceContext = "trace-context" AllowedEventIDChars = `^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$` // fully-qualified topic name components AllowedSourceIdChars = `^[a-zA-Z]+([_\-\.]?[a-zA-Z0-9]+)*$` AllowedEventTypeChars = `^[a-zA-Z]+([_\-\.]?[a-zA-Z0-9]+)*$` AllowedEventTypeVersionChars = `^[a-zA-Z0-9]+$` HeaderSourceId = "Source-Id" )
View Source
const ( /*ErrorTypeBadPayload The request payload has incorrect syntax according to the sent Content-Type. Check the payload content for syntax errors, such as missing commas or quotation marks that are not closed. */ ErrorTypeBadPayload = "bad_payload_syntax" /*ErrorTypeValidationViolation Top level validation error. */ ErrorTypeValidationViolation = "validation_violation" /*ErrorTypeMissingField Sub-level error type of `ErrorTypeValidationViolation` representaing that the requested body payload for a POST or PUT operation is missing, which violates the defined validation constraints. This denotes a missing field when a value is expected. */ ErrorTypeMissingField = "missing_field" ErrorTypeMissingFieldOrHeader = "missing_field/missing_header" /*ErrorTypeInvalidField Sub-level error type of `ErrorTypeValidationViolation` representaing that the requested body payload for the POST or PUT operation violates the validation constraints. This denotes specifically that there is: - A type incompatibility, such as a field modeled to be an integer, but a non-numeric expression was found instead. - A range under or over flow validation violation cause. */ ErrorTypeInvalidField = "invalid_field" ErrorTypeInvalidHeader = "invalid_header" // ErrorTypeInternalServerError Some unexpected internal error occurred while processing the request. ErrorTypeInternalServerError = "internal_server_error" // ErrorMessageInternalServerError represents the error message for `ErrorTypeInternalServerError` ErrorMessageInternalServerError = "Some unexpected internal error occurred, please contact support." /*ErrorTypeBadRequest A generic error for bad requests sent by the clients. Use when none of the specific error types apply. */ ErrorTypeBadRequest = "bad_request" // ErrorMessageBadRequest represents the error message for `ErrorTypeBadRequest` ErrorMessageBadRequest = "Some unexpected internal error occurred, please contact support." // ErrorMessageBadPayload represents the error message for `ErrorTypeBadPayload` ErrorMessageBadPayload = "Something went very wrong. Please try again." // ErrorMessageMissingField represents the error message for `ErrorTypeMissingField` ErrorMessageMissingField = "We need all required fields complete to keep you moving." // ErrorMessageInvalidField represents the error message for `ErrorTypeInvalidField` ErrorMessageInvalidField = "We need all your entries to be correct to keep you moving." ErrorMessageMissingSourceId = "Either provide 'Source-Id' header or specify 'source-id' in the json payload" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudEvent ¶
type CloudEvent struct { PublishRequest Extensions Extensions `json:"extensions,omitempty"` }
CloudEvent represents the event to be persisted to NATS
type Error ¶
type Error struct { Status int `json:"status"` Type string `json:"type"` Message string `json:"message"` MoreInfo string `json:"moreInfo"` Details []ErrorDetail `json:"details"` }
Error represents API error response code
func ErrorResponseBadPayload ¶
func ErrorResponseBadPayload() (response *Error)
func ErrorResponseBadRequest ¶
func ErrorResponseBadRequest() (response *Error)
func ErrorResponseEmptyRequest ¶
func ErrorResponseEmptyRequest() (response *Error)
func ErrorResponseInternalServer ¶
func ErrorResponseInternalServer() (response *Error)
TODO Add proper comments
func ErrorResponseMissingFieldData ¶
func ErrorResponseMissingFieldData() (response *Error)
func ErrorResponseMissingFieldEventTime ¶
func ErrorResponseMissingFieldEventTime() (response *Error)
func ErrorResponseMissingFieldEventType ¶
func ErrorResponseMissingFieldEventType() (response *Error)
func ErrorResponseMissingFieldEventTypeVersion ¶
func ErrorResponseMissingFieldEventTypeVersion() (response *Error)
func ErrorResponseMissingFieldSourceId ¶
func ErrorResponseMissingFieldSourceId() (response *Error)
func ErrorResponseWrongEventId ¶
func ErrorResponseWrongEventId() (response *Error)
func ErrorResponseWrongEventType ¶
func ErrorResponseWrongEventType() (response *Error)
func ErrorResponseWrongEventTypeVersion ¶
func ErrorResponseWrongEventTypeVersion() (response *Error)
func ValidatePublish ¶
func ValidatePublish(r *PublishRequest) *Error
ValidatePublish validates a publish POST request
type ErrorDetail ¶
type ErrorDetail struct { Field string `json:"field"` Type string `json:"type"` Message string `json:"message"` MoreInfo string `json:"moreInfo"` }
ErrorDetail represents error cause
type Extensions ¶
type Extensions = map[string]interface{}
type PublishRequest ¶
type PublishRequest struct { SourceID string `json:"source-id"` EventType string `json:"event-type"` EventTypeVersion string `json:"event-type-version"` EventID string `json:"event-id"` EventTime string `json:"event-time"` Data AnyValue `json:"data"` SourceIdFromHeader bool }
PublishRequest represents a publish request
type PublishResponse ¶
type PublishResponse struct {
EventID string `json:"event-id"`
}
PublishResponse represents a successful publish response
type TraceContext ¶
Click to show internal directories.
Click to hide internal directories.