| 1 | package gotifyscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/ |
| 2 | |
| 3 | import ( |
| 4 | "crypto/tlsscip-go gomod github.com/golang/go/src . `crypto/tls`/" |
| 5 | "net/httpscip-go gomod github.com/golang/go/src . `net/http`/" |
| 6 | "timescip-go gomod github.com/golang/go/src . time/" |
| 7 | |
| 8 | "github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/" |
| 9 | ) |
| 10 | |
| 11 | // HTTPClientManager handles HTTP client creation and configuration. |
| 12 | type HTTPClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPClientManager# interface { |
| 13 | CreateTransportscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPClientManager#CreateTransport.(config *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#) *httpscip-go gomod github.com/golang/go/src . `net/http`/.Transportscip-go gomod github.com/golang/go/src . `net/http`/Transport# |
| 14 | CreateClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPClientManager#CreateClient.(transport *httpscip-go gomod github.com/golang/go/src . `net/http`/.Transportscip-go gomod github.com/golang/go/src . `net/http`/Transport#) *httpscip-go gomod github.com/golang/go/src . `net/http`/.Clientscip-go gomod github.com/golang/go/src . `net/http`/Client# |
| 15 | } |
| 16 | |
| 17 | // DefaultHTTPClientManager provides the default implementation of HTTPClientManager. |
| 18 | type DefaultHTTPClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultHTTPClientManager# struct{} |
| 19 | |
| 20 | const ( |
| 21 | // HTTPTimeout defines the HTTP client timeout in seconds. |
| 22 | HTTPTimeoutscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPTimeout. = 10 |
| 23 | ) |
| 24 | |
| 25 | // CreateClient creates an HTTP client with timeout and transport. |
| 26 | // This method assembles an HTTP client with the configured transport and timeout settings |
| 27 | // to ensure reliable API communication with appropriate performance characteristics. |
| 28 | // Parameters: |
| 29 | // - transport: The HTTP transport with TLS and proxy configuration |
| 30 | // |
| 31 | // Returns: *http.Client ready for making API requests with proper timeout and transport settings. |
| 32 | func (m *DefaultHTTPClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultHTTPClientManager#) CreateClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultHTTPClientManager#CreateClient().(transport *httpscip-go gomod github.com/golang/go/src . `net/http`/.Transportscip-go gomod github.com/golang/go/src . `net/http`/Transport#) *httpscip-go gomod github.com/golang/go/src . `net/http`/.Clientscip-go gomod github.com/golang/go/src . `net/http`/Client# { |
| 33 | return &httpscip-go gomod github.com/golang/go/src . `net/http`/.Clientscip-go gomod github.com/golang/go/src . `net/http`/Client#{ |
| 34 | Transportscip-go gomod github.com/golang/go/src . `net/http`/Client#Transport.: transport, // Use the configured transport for TLS and proxy handling |
| 35 | Timeoutscip-go gomod github.com/golang/go/src . `net/http`/Client#Timeout.: HTTPTimeoutscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPTimeout. * timescip-go gomod github.com/golang/go/src . time/.Secondscip-go gomod github.com/golang/go/src . time/Second., // Set timeout to prevent hanging requests |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // CreateTransport sets up the HTTP transport with TLS configuration and proxy settings. |
| 40 | // This method configures the underlying HTTP transport layer with appropriate security settings |
| 41 | // based on the service configuration, particularly handling TLS verification preferences. |
| 42 | // Returns: *http.Transport configured with TLS settings for secure or insecure connections. |
| 43 | // |
| 44 | |
| 45 | func (m *DefaultHTTPClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultHTTPClientManager#) CreateTransportscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultHTTPClientManager#CreateTransport().(config *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#) *httpscip-go gomod github.com/golang/go/src . `net/http`/.Transportscip-go gomod github.com/golang/go/src . `net/http`/Transport# { |
| 46 | return &httpscip-go gomod github.com/golang/go/src . `net/http`/.Transportscip-go gomod github.com/golang/go/src . `net/http`/Transport#{ |
| 47 | TLSClientConfigscip-go gomod github.com/golang/go/src . `net/http`/Transport#TLSClientConfig.: &tlsscip-go gomod github.com/golang/go/src . `crypto/tls`/.Configscip-go gomod github.com/golang/go/src . `crypto/tls`/Config#{ |
| 48 | MinVersionscip-go gomod github.com/golang/go/src . `crypto/tls`/Config#MinVersion.: tlsscip-go gomod github.com/golang/go/src . `crypto/tls`/.VersionTLS12scip-go gomod github.com/golang/go/src . `crypto/tls`/VersionTLS12., |
| 49 | InsecureSkipVerifyscip-go gomod github.com/golang/go/src . `crypto/tls`/Config#InsecureSkipVerify.: config.DisableTLSscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#DisableTLS. || |
| 50 | config.InsecureSkipVerifyscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#InsecureSkipVerify., |
| 51 | }, |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // initClient initializes the HTTP client and related components. |
| 56 | // This method ensures that the transport, HTTP client, JSON client, |
| 57 | // and TLS warning logging are performed when needed, allowing re-initialization if the client becomes nil. |
| 58 | // This function is called by the Service and modifies its fields. |
| 59 | func initClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/initClient().(service *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#, manager HTTPClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPClientManager#) { |
| 60 | service.muscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#mu..Lockscip-go gomod github.com/golang/go/src . sync/Mutex#Lock().() |
| 61 | defer service.muscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#mu..Unlockscip-go gomod github.com/golang/go/src . sync/Mutex#Unlock().() |
| 62 | |
| 63 | if service.httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient. == nil || service.clientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#client. == nil { |
| 64 | transport := manager.CreateTransportscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPClientManager#CreateTransport.(service.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config.) |
| 65 | service.httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient. = manager.CreateClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPClientManager#CreateClient.(transport) |
| 66 | |
| 67 | service.clientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#client. = jsonclientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/.NewWithHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/NewWithHTTPClient().(service.httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient.) |
| 68 | if service.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config..DisableTLSscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#DisableTLS. { |
| 69 | service.Logscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/Logger#Log().("Warning: TLS is disabled, using insecure HTTP connections") |
| 70 | } |
| 71 | |
| 72 | if service.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config..InsecureSkipVerifyscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#InsecureSkipVerify. { |
| 73 | service.Logscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/Logger#Log().("Warning: TLS certificate verification is disabled") |
| 74 | } |
| 75 | } |
| 76 | } |