Documentation ¶
Index ¶
- Constants
- type AnyValue
- type CloudEvent
- type Error
- func CreateInvalidFieldError(field interface{}) (response *Error)
- func CreateMissingFieldError(field interface{}) (response *Error)
- func ErrorInvalidEventTypeLength(eventTypeMaxLength int) *Error
- func ErrorInvalidEventTypeVersionLength(eventTypeVersionMaxLength int) *Error
- func ErrorInvalidFieldLength(field string, length int) *Error
- func ErrorInvalidSourceIDLength(sourceIDMaxLength int) *Error
- func ErrorResponseBadPayload() (response *Error)
- func ErrorResponseBadRequest() (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 ErrorResponseRequestBodyTooLarge() (response *Error)
- func ErrorResponseWrongEventID() (response *Error)
- func ErrorResponseWrongEventTime() (response *Error)
- func ErrorResponseWrongEventType() (response *Error)
- func ErrorResponseWrongEventTypeVersion() (response *Error)
- func ErrorResponseWrongSourceID(sourceIDFromHeader bool) (response *Error)
- type ErrorDetail
- type EventOptions
- type Extensions
- type Request
- type Response
- type TraceContext
Constants ¶
const ( // FieldData value FieldData = "data" // FieldEventID value FieldEventID = "event-id" // FieldEventTime value FieldEventTime = "event-time" // FieldEventType value FieldEventType = "event-type" // FieldEventTypeVersion value FieldEventTypeVersion = "event-type-version" // FieldSourceID value FieldSourceID = "source-id" // FieldTraceContext value FieldTraceContext = "trace-context" // AllowedEventIDChars regex 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}$` // AllowedSourceIDChars regex AllowedSourceIDChars = `^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$` // AllowedEventTypeChars regex AllowedEventTypeChars = `^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$` // AllowedEventTypeVersionChars regex AllowedEventTypeVersionChars = `^[a-zA-Z0-9]+$` // HeaderSourceID heaver HeaderSourceID = "Source-Id" )
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 error type for a missing field or header. 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 is error type code for invalid header ErrorTypeInvalidHeader = "invalid_header" // ErrorTypeInvalidFieldLength is error type code for invalid field length ErrorTypeInvalidFieldLength = "invalid_field_length" // ErrorTypeRequestBodyTooLarge is error type code for error responses where request body is too large ErrorTypeRequestBodyTooLarge = "request_body_too_large" // ErrorMessageRequestBodyTooLarge is error message for error responses where request body is too large ErrorMessageRequestBodyTooLarge = "Request body too large" // 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." // ErrorMessageInvalidFieldLength represents the error message for `ErrorTypeInvalidFieldLength` ErrorMessageInvalidFieldLength = "Field length must be at max: %d" // ErrorMessageMissingSourceID represents the error message for `ErrorTypeMissingFieldOrHeader` ErrorMessageMissingSourceID = "Either provide 'Source-Id' header or specify 'source-id' in the json payload" )
const ( // DefaultMaxSourceIDLength default value DefaultMaxSourceIDLength = 253 // DefaultMaxEventTypeLength default value DefaultMaxEventTypeLength = 253 // DefaultMaxEventTypeVersionLength default value DefaultMaxEventTypeVersionLength = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudEvent ¶
type CloudEvent struct { Request 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 CreateInvalidFieldError ¶
func CreateInvalidFieldError(field interface{}) (response *Error)
CreateInvalidFieldError creates an Error for an invalid field
func CreateMissingFieldError ¶
func CreateMissingFieldError(field interface{}) (response *Error)
CreateMissingFieldError creates an Error for a missing field
func ErrorInvalidEventTypeLength ¶
ErrorInvalidEventTypeLength creates an API Error response in case Event Type length exceeded the maximum
func ErrorInvalidEventTypeVersionLength ¶
ErrorInvalidEventTypeVersionLength creates an API Error response in case Event Type Version length exceeded the maximum
func ErrorInvalidFieldLength ¶
ErrorInvalidFieldLength returns an API error instance for the invalid field length error.
func ErrorInvalidSourceIDLength ¶
ErrorInvalidSourceIDLength creates an API Error response in case Source ID length exceeded the maximum
func ErrorResponseBadPayload ¶
func ErrorResponseBadPayload() (response *Error)
ErrorResponseBadPayload returns an API error instance for the bad payload error.
func ErrorResponseBadRequest ¶
func ErrorResponseBadRequest() (response *Error)
ErrorResponseBadRequest returns an API error instance for the bad request error.
func ErrorResponseInternalServer ¶
func ErrorResponseInternalServer() (response *Error)
ErrorResponseInternalServer creates API Error response for case of internal server error.
func ErrorResponseMissingFieldData ¶
func ErrorResponseMissingFieldData() (response *Error)
ErrorResponseMissingFieldData returns an API error instance for the missing field data error.
func ErrorResponseMissingFieldEventTime ¶
func ErrorResponseMissingFieldEventTime() (response *Error)
ErrorResponseMissingFieldEventTime returns an API error instance for the missing field event time error.
func ErrorResponseMissingFieldEventType ¶
func ErrorResponseMissingFieldEventType() (response *Error)
ErrorResponseMissingFieldEventType returns an API error instance for the missing field event type error.
func ErrorResponseMissingFieldEventTypeVersion ¶
func ErrorResponseMissingFieldEventTypeVersion() (response *Error)
ErrorResponseMissingFieldEventTypeVersion returns an API error instance for the missing field event type version error.
func ErrorResponseMissingFieldSourceID ¶
func ErrorResponseMissingFieldSourceID() (response *Error)
ErrorResponseMissingFieldSourceID returns an API error instance for the missing field source ID error.
func ErrorResponseRequestBodyTooLarge ¶
func ErrorResponseRequestBodyTooLarge() (response *Error)
ErrorResponseRequestBodyTooLarge creates API Error response for case of request body being too large
func ErrorResponseWrongEventID ¶
func ErrorResponseWrongEventID() (response *Error)
ErrorResponseWrongEventID returns an API error instance for the wrong event ID error.
func ErrorResponseWrongEventTime ¶
func ErrorResponseWrongEventTime() (response *Error)
ErrorResponseWrongEventTime returns an API error instance for the wrong event time error.
func ErrorResponseWrongEventType ¶
func ErrorResponseWrongEventType() (response *Error)
ErrorResponseWrongEventType returns an API error instance for the wrong event type error.
func ErrorResponseWrongEventTypeVersion ¶
func ErrorResponseWrongEventTypeVersion() (response *Error)
ErrorResponseWrongEventTypeVersion returns an API error instance for the wrong event type version error.
func ErrorResponseWrongSourceID ¶
ErrorResponseWrongSourceID returns an API error instance for the wrong source ID error.
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 EventOptions ¶
type EventOptions struct { MaxSourceIDLength int MaxEventTypeLength int MaxEventTypeVersionLength int }
EventOptions represents the event options.
func GetDefaultEventOptions ¶
func GetDefaultEventOptions() *EventOptions
GetDefaultEventOptions returns a new default event options instance.
type Request ¶
type Request 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 }
Request represents a publish request