File: client.go

package info (click to toggle)
golang-github-docker-engine-api 0.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,064 kB
  • sloc: makefile: 19
file content (47 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package transport

import (
	"crypto/tls"
	"net/http"
)

// Sender is an interface that clients must implement
// to be able to send requests to a remote connection.
type Sender interface {
	// Do sends request to a remote endpoint.
	Do(*http.Request) (*http.Response, error)
}

// Client is an interface that abstracts all remote connections.
type Client interface {
	Sender
	// Secure tells whether the connection is secure or not.
	Secure() bool
	// Scheme returns the connection protocol the client uses.
	Scheme() string
	// TLSConfig returns any TLS configuration the client uses.
	TLSConfig() *tls.Config
}

// tlsInfo returns information about the TLS configuration.
type tlsInfo struct {
	tlsConfig *tls.Config
}

// TLSConfig returns the TLS configuration.
func (t *tlsInfo) TLSConfig() *tls.Config {
	return t.tlsConfig
}

// Scheme returns protocol scheme to use.
func (t *tlsInfo) Scheme() string {
	if t.tlsConfig != nil {
		return "https"
	}
	return "http"
}

// Secure returns true if there is a TLS configuration.
func (t *tlsInfo) Secure() bool {
	return t.tlsConfig != nil
}