http.HandlerFunc is a Go function type that adapts a function with the HTTP handler signature to the http.Handler interface. The adapter lets a regular function or closure serve requests wherever an http.Handler is required. section 8.10 section 8.3.2
Its ServeHTTP method receives a ResponseWriter and Request, then calls the wrapped function. This preserves the simple function implementation while satisfying the interface expected by HTTP servers and test servers. section 8.3.2
Serve a function with ListenAndServe
A named Health function can be converted directly when starting a server: http.ListenAndServe("localhost:8080", http.HandlerFunc(Health)). The server calls Health for each incoming request through ServeHTTP. section 8.3.2
Create a closure-backed handler
A function such as Shorten can return http.HandlerFunc around a closure that uses injected dependencies. The closure processes the request, writes a response, and returns immediately after an error to prevent further side effects. section 8.4.1
Test with httptest.Server
Wrap a closure with http.HandlerFunc and pass it to httptest.NewServer. The server invokes the closure for incoming requests; use server.URL to address it and server.Close to release resources. section 7.6.1

