-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding pipeline behaviors to mediatr and its tests
- Loading branch information
mehdihadeli
committed
Aug 5, 2022
1 parent
77c2050
commit 8dc1be3
Showing
7 changed files
with
301 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
examples/cqrs/internal/shared/behaviours/request_logger_behaviour.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package behaviours | ||
|
||
import ( | ||
"context" | ||
"github.com/mehdihadeli/mediatr" | ||
"log" | ||
) | ||
|
||
type RequestLoggerBehaviour struct { | ||
} | ||
|
||
func (r *RequestLoggerBehaviour) Handle(ctx context.Context, request interface{}, next mediatr.RequestHandlerFunc) (interface{}, error) { | ||
log.Printf("logging some stuff before handling the request") | ||
|
||
response, err := next() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
log.Println("logging some stuff after handling the request") | ||
|
||
return response, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.