MCPcopy
hub / github.com/gofiber/fiber / adaptHTTPHandler

Function adaptHTTPHandler

adapter.go:194–218  ·  view source on GitHub ↗
(handler any)

Source from the content-addressed store, hash-verified

192}
193
194func 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
220func isNilableKind(kind reflect.Kind) bool {
221 switch kind {

Callers 1

toFiberHandlerFunction · 0.85

Calls 2

wrapHTTPHandlerFunction · 0.85
isNilableKindFunction · 0.85

Tested by

no test coverage detected