ab4a9f0480
Since the repo is no longer just the registry, we are moving the registry web application package out of the repo root into a sub-package. We may break down the registry package further to separate webapp components and bring the client package under it. This change accomplishes the task of freeing up the repo root for a distribution-oriented package. A stub doc.go file is left in place to declare intent. Signed-off-by: Stephen J Day <stephen.day@docker.com>
27 lines
619 B
Go
27 lines
619 B
Go
package registry
|
|
|
|
import (
|
|
"net/http"
|
|
"reflect"
|
|
"runtime"
|
|
|
|
"github.com/gorilla/handlers"
|
|
)
|
|
|
|
// functionName returns the name of the function fn.
|
|
func functionName(fn interface{}) string {
|
|
return runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
|
|
}
|
|
|
|
// resolveHandlerName attempts to resolve a nice, pretty name for the passed
|
|
// in handler.
|
|
func resolveHandlerName(method string, handler http.Handler) string {
|
|
switch v := handler.(type) {
|
|
case handlers.MethodHandler:
|
|
return functionName(v[method])
|
|
case http.HandlerFunc:
|
|
return functionName(v)
|
|
default:
|
|
return functionName(handler.ServeHTTP)
|
|
}
|
|
}
|