(requestHandlerFuncs []ContextRequestFunc[T])
| 172 | } |
| 173 | |
| 174 | func joinContextRequestFuncs[T any](requestHandlerFuncs []ContextRequestFunc[T]) ContextRequestFunc[T] { |
| 175 | if len(requestHandlerFuncs) == 0 || requestHandlerFuncs[0] == nil { |
| 176 | panic("at least one context request handler function is required") |
| 177 | } |
| 178 | |
| 179 | if len(requestHandlerFuncs) == 1 { |
| 180 | return requestHandlerFuncs[0] |
| 181 | } |
| 182 | |
| 183 | return func(ctx *context.Context, req T) error { |
| 184 | for _, handler := range requestHandlerFuncs { |
| 185 | if handler == nil { |
| 186 | continue |
| 187 | } |
| 188 | |
| 189 | if err := handler(ctx, req); err != nil { |
| 190 | return err |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | return nil |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | // RequestHandler is an interface which can be implemented by a request payload struct |
| 199 | // in order to validate the context before calling a service function. |
nothing calls this directly
no test coverage detected
searching dependent graphs…