本文整理汇总了Golang中net/http.Transport.RegisterProtocol方法的典型用法代码示例。如果您正苦于以下问题:Golang Transport.RegisterProtocol方法的具体用法?Golang Transport.RegisterProtocol怎么用?Golang Transport.RegisterProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/http.Transport
的用法示例。
在下文中一共展示了Transport.RegisterProtocol方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: registerHTTPSProtocol
// registerHTTPSProtocol calls Transport.RegisterProtocol but
// convering panics into errors.
func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error) {
defer func() {
if e := recover(); e != nil {
err = fmt.Errorf("%v", e)
}
}()
t.RegisterProtocol("https", rt)
return nil
}
示例2: New
// New returns a Supervisor interface type connected to the net.URL specified in u
//
// Optionally specify a http.Transport to use, will use default http.Transport if nil.
// This will also register a
func New(url string, transport *http.Transport) Supervisor {
if transport == nil {
transport = new(http.Transport)
}
transport.RegisterProtocol("unix", new(supervisorTransport))
//xmlrpc.NewClient never returns an error
client, _ := xmlrpc.NewClient(url, transport)
return &supervisor{client}
}
示例3: registerFileProtocol
// registerFileProtocol registers support for file:// URLs on the given transport.
func registerFileProtocol(transport *http.Transport) {
transport.RegisterProtocol("file", http.NewFileTransport(http.Dir("/")))
}
示例4: NewClient
func (t *UnleashedTransport) NewClient() *http.Client {
transport := new(http.Transport)
transport.RegisterProtocol(SchemeName, t)
return &http.Client{Transport: transport}
}