feat(project): 项目完结
This commit is contained in:
19
internal/domain/shared/tree/router.go
Normal file
19
internal/domain/shared/tree/router.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package tree
|
||||
|
||||
import "context"
|
||||
|
||||
type Handler[C any, D any, R any] interface {
|
||||
Apply(ctx context.Context, command C, dynamic D) (R, error)
|
||||
}
|
||||
|
||||
func Route[C any, D any, R any](ctx context.Context, next Handler[C, D, R], command C, dynamic D) (R, error) {
|
||||
if next == nil {
|
||||
return zero[R](), nil
|
||||
}
|
||||
return next.Apply(ctx, command, dynamic)
|
||||
}
|
||||
|
||||
func zero[T any]() T {
|
||||
var value T
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user