@@ -38,8 +38,24 @@ func (h *PublishHandlers) Ingest(c *gin.Context) {
3838 if err := h .eventHandler .Handle (c .Request .Context (), & event ); err != nil {
3939 if errors .Is (err , idempotence .ErrConflict ) {
4040 c .Status (http .StatusConflict )
41+ } else if errors .Is (err , publishmq .ErrRequiredTopic ) {
42+ AbortWithValidationError (c , ErrorResponse {
43+ Code : http .StatusUnprocessableEntity ,
44+ Message : "validation error" ,
45+ Err : err ,
46+ Data : map [string ]string {
47+ "topic" : "required" ,
48+ },
49+ })
4150 } else if errors .Is (err , publishmq .ErrInvalidTopic ) {
42- AbortWithValidationError (c , err )
51+ AbortWithValidationError (c , ErrorResponse {
52+ Code : http .StatusUnprocessableEntity ,
53+ Message : "validation error" ,
54+ Err : err ,
55+ Data : map [string ]string {
56+ "topic" : "invalid" ,
57+ },
58+ })
4359 } else {
4460 AbortWithError (c , http .StatusInternalServerError , NewErrInternalServer (err ))
4561 }
@@ -48,10 +64,9 @@ func (h *PublishHandlers) Ingest(c *gin.Context) {
4864 c .Status (http .StatusOK )
4965}
5066
51- // TODO: validation
5267type PublishedEvent struct {
5368 ID string `json:"id"`
54- TenantID string `json:"tenant_id"`
69+ TenantID string `json:"tenant_id" binding:"required" `
5570 DestinationID string `json:"destination_id"`
5671 Topic string `json:"topic"`
5772 EligibleForRetry bool `json:"eligible_for_retry"`
0 commit comments