MCPcopy Create free account
hub / github.com/chain/Core / Handler

Function Handler

net/http/httpjson/handler.go:32–41  ·  view source on GitHub ↗

Handler returns an HTTP handler for function f. See the package doc for details on allowed signatures for f. If f returns a non-nil error, the handler will call errFunc.

(f interface{}, errFunc ErrorWriter)

Source from the content-addressed store, hash-verified

30// See the package doc for details on allowed signatures for f.
31// If f returns a non-nil error, the handler will call errFunc.
32func Handler(f interface{}, errFunc ErrorWriter) (http.Handler, error) {
33 fv := reflect.ValueOf(f)
34 hasCtx, inType, err := funcInputType(fv)
35 if err != nil {
36 return nil, err
37 }
38
39 h := &handler{fv, inType, hasCtx, errFunc}
40 return h, nil
41}
42
43func (h *handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
44 var a []reflect.Value

Callers 4

TestContextFunction · 0.70
TestHandlerFunction · 0.70
TestReadErrFunction · 0.70
TestFuncInputTypeErrorFunction · 0.70

Calls 1

funcInputTypeFunction · 0.85

Tested by 4

TestContextFunction · 0.56
TestHandlerFunction · 0.56
TestReadErrFunction · 0.56
TestFuncInputTypeErrorFunction · 0.56