@@ -3,15 +3,15 @@ package middleware
33import (
44 "context"
55
6- "github.com/bxcodec/goqu "
6+ "github.com/bxcodec/goqueue "
77 "github.com/sirupsen/logrus"
88)
99
1010// ApplyHandlerMiddleware applies a series of middleware functions to an inbound message handler function.
1111// It takes an inbound message handler function `h` and a variadic list of middleware functions `middleware`.
1212// Each middleware function is applied to the handler function in the order they are provided.
1313// The resulting handler function with all the middleware applied is returned.
14- func ApplyHandlerMiddleware (h goqu .InboundMessageHandlerFunc , middleware ... goqu .InboundMessageHandlerMiddlewareFunc ) goqu .InboundMessageHandlerFunc {
14+ func ApplyHandlerMiddleware (h goqueue .InboundMessageHandlerFunc , middleware ... goqueue .InboundMessageHandlerMiddlewareFunc ) goqueue .InboundMessageHandlerFunc {
1515 for _ , middleware := range middleware {
1616 h = middleware (h )
1717 }
@@ -21,7 +21,7 @@ func ApplyHandlerMiddleware(h goqu.InboundMessageHandlerFunc, middleware ...goqu
2121// ApplyPublisherMiddleware applies the given publisher middleware functions to the provided publisher function.
2222// It iterates over the middleware functions and applies them in the order they are provided.
2323// The resulting publisher function is returned.
24- func ApplyPublisherMiddleware (p goqu .PublisherFunc , middleware ... goqu .PublisherMiddlewareFunc ) goqu .PublisherFunc {
24+ func ApplyPublisherMiddleware (p goqueue .PublisherFunc , middleware ... goqueue .PublisherMiddlewareFunc ) goqueue .PublisherFunc {
2525 for _ , middleware := range middleware {
2626 p = middleware (p )
2727 }
@@ -32,9 +32,9 @@ func ApplyPublisherMiddleware(p goqu.PublisherFunc, middleware ...goqu.Publisher
3232// It wraps the provided `next` inbound message handler function and executes some additional logic after it.
3333// The additional logic includes logging any error that occurred during the execution of the `next` function
3434// and logging a message indicating that the middleware has been executed.
35- func HelloWorldMiddlewareExecuteAfterHandler () goqu .InboundMessageHandlerMiddlewareFunc {
36- return func (next goqu .InboundMessageHandlerFunc ) goqu .InboundMessageHandlerFunc {
37- return func (ctx context.Context , m goqu .InboundMessage ) (err error ) {
35+ func HelloWorldMiddlewareExecuteAfterHandler () goqueue .InboundMessageHandlerMiddlewareFunc {
36+ return func (next goqueue .InboundMessageHandlerFunc ) goqueue .InboundMessageHandlerFunc {
37+ return func (ctx context.Context , m goqueue .InboundMessage ) (err error ) {
3838 err = next (ctx , m )
3939 if err != nil {
4040 logrus .Error ("Error: " , err , "processing to sent the error to Sentry" )
@@ -46,9 +46,9 @@ func HelloWorldMiddlewareExecuteAfterHandler() goqu.InboundMessageHandlerMiddlew
4646}
4747
4848// HelloWorldMiddlewareExecuteBeforeHandler returns a middleware function that logs a message before executing the handler.
49- func HelloWorldMiddlewareExecuteBeforeHandler () goqu .InboundMessageHandlerMiddlewareFunc {
50- return func (next goqu .InboundMessageHandlerFunc ) goqu .InboundMessageHandlerFunc {
51- return func (ctx context.Context , m goqu .InboundMessage ) (err error ) {
49+ func HelloWorldMiddlewareExecuteBeforeHandler () goqueue .InboundMessageHandlerMiddlewareFunc {
50+ return func (next goqueue .InboundMessageHandlerFunc ) goqueue .InboundMessageHandlerFunc {
51+ return func (ctx context.Context , m goqueue .InboundMessage ) (err error ) {
5252 logrus .Info ("hello-world-first-middleware executed" )
5353 return next (ctx , m )
5454 }
@@ -57,9 +57,9 @@ func HelloWorldMiddlewareExecuteBeforeHandler() goqu.InboundMessageHandlerMiddle
5757
5858// HelloWorldMiddlewareExecuteAfterPublisher returns a PublisherMiddlewareFunc that executes after the publisher function.
5959// It logs any error that occurs during publishing and logs a message indicating that the last middleware has been executed.
60- func HelloWorldMiddlewareExecuteAfterPublisher () goqu .PublisherMiddlewareFunc {
61- return func (next goqu .PublisherFunc ) goqu .PublisherFunc {
62- return func (ctx context.Context , m goqu .Message ) (err error ) {
60+ func HelloWorldMiddlewareExecuteAfterPublisher () goqueue .PublisherMiddlewareFunc {
61+ return func (next goqueue .PublisherFunc ) goqueue .PublisherFunc {
62+ return func (ctx context.Context , m goqueue .Message ) (err error ) {
6363 err = next (ctx , m )
6464 if err != nil {
6565 logrus .Error ("got error while publishing the message: " , err )
@@ -73,9 +73,9 @@ func HelloWorldMiddlewareExecuteAfterPublisher() goqu.PublisherMiddlewareFunc {
7373
7474// HelloWorldMiddlewareExecuteBeforePublisher is a function that returns a PublisherMiddlewareFunc.
7575// It wraps the provided PublisherFunc with a middleware that logs a message before executing the next function.
76- func HelloWorldMiddlewareExecuteBeforePublisher () goqu .PublisherMiddlewareFunc {
77- return func (next goqu .PublisherFunc ) goqu .PublisherFunc {
78- return func (ctx context.Context , e goqu .Message ) (err error ) {
76+ func HelloWorldMiddlewareExecuteBeforePublisher () goqueue .PublisherMiddlewareFunc {
77+ return func (next goqueue .PublisherFunc ) goqueue .PublisherFunc {
78+ return func (ctx context.Context , e goqueue .Message ) (err error ) {
7979 logrus .Info ("hello-world-first-middleware executed" )
8080 return next (ctx , e )
8181 }
0 commit comments