From c4c55c0fa591b2e354dbb085e0e1c83bb3bce210 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Thu, 11 Feb 2016 12:14:07 +0100 Subject: clients: cleanup --- clients/common.go | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'clients/common.go') diff --git a/clients/common.go b/clients/common.go index 24b3d63..039404d 100644 --- a/clients/common.go +++ b/clients/common.go @@ -20,14 +20,7 @@ import ( "gopkg.in/src-d/go-git.v2/clients/ssh" ) -// ServiceFromURLFunc defines a service returning function for a given -// URL. -type ServiceFromURLFunc func(url string) common.GitUploadPackService - // DefaultProtocols are the protocols supported by default. -// Wrapping is needed because you can not cast a function that -// returns an implementation of an interface to a function that -// returns the interface. var DefaultProtocols = map[string]common.GitUploadPackService{ "http": http.NewGitUploadPackService(), "https": http.NewGitUploadPackService(), @@ -41,8 +34,17 @@ var KnownProtocols = make(map[string]common.GitUploadPackService, len(DefaultPro func init() { for k, v := range DefaultProtocols { - KnownProtocols[k] = v + InstallProtocol(k, v) + } +} + +// InstallProtocol adds or modifies an existing protocol. +func InstallProtocol(scheme string, service common.GitUploadPackService) { + if service == nil { + panic("nil service") } + + KnownProtocols[scheme] = service } // NewGitUploadPackService returns the appropiate upload pack service @@ -60,12 +62,3 @@ func NewGitUploadPackService(repoURL string) (common.GitUploadPackService, error return service, nil } - -// InstallProtocol adds or modifies an existing protocol. -func InstallProtocol(scheme string, service common.GitUploadPackService) { - if service == nil { - panic("nil service") - } - - KnownProtocols[scheme] = service -} -- cgit