(handler any)
| 192 | } |
| 193 | |
| 194 | func adaptHTTPHandler(handler any) (Handler, bool) { |
| 195 | switch h := handler.(type) { |
| 196 | case http.HandlerFunc: // (13) net/http HandlerFunc |
| 197 | if h == nil { |
| 198 | return nil, false |
| 199 | } |
| 200 | return wrapHTTPHandler(h), true |
| 201 | case http.Handler: // (14) net/http Handler implementation |
| 202 | if h == nil { |
| 203 | return nil, false |
| 204 | } |
| 205 | hv := reflect.ValueOf(h) |
| 206 | if isNilableKind(hv.Kind()) && hv.IsNil() { |
| 207 | return nil, false |
| 208 | } |
| 209 | return wrapHTTPHandler(h), true |
| 210 | case func(http.ResponseWriter, *http.Request): // (15) net/http function handler |
| 211 | if h == nil { |
| 212 | return nil, false |
| 213 | } |
| 214 | return wrapHTTPHandler(http.HandlerFunc(h)), true |
| 215 | default: |
| 216 | return nil, false |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func isNilableKind(kind reflect.Kind) bool { |
| 221 | switch kind { |
no test coverage detected