{"modulePath":"github.com/nmintoh/dserver","version":"v5.11.1+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package httpservice\n\n## Constants\n\n```go\nconst (\n\tConnectTimeout = 3 * time.Second\n\tRequestTimeout = 30 * time.Second\n)\n```\n\n## Variables\n\n```go\nvar AddressForbidden error = errors.New(\"address forbidden, you may need to set AllowedUntrustedInternalConnections to allow an integration access to your internal network\")\n```\n\n## Functions\n\n```go\nfunc IsOwnIP(ip net.IP) (bool, error)\n```\nIsOwnIP handles the special case that a request might be made to the public IP of the host which on Linux is routed directly via the loopback IP to any listening sockets, effectively bypassing host-based firewalls such as firewalld\n\n```go\nfunc IsReservedIP(ip net.IP) bool\n```\nIsReservedIP checks whether the target IP belongs to reserved IP address ranges to avoid SSRF attacks to the internal network of the Mattermost server\n\n```go\nfunc NewTransport(enableInsecureConnections bool, allowHost func(host string) bool, allowIP func(ip net.IP) bool) http.RoundTripper\n```\n\n## Types\n\n```go\ntype DialContextFunction func(ctx context.Context, network, addr string) (net.Conn, error)\n```\n\n```go\ntype HTTPService interface {\n\t// MakeClient returns an http client constructed with a RoundTripper as returned by MakeTransport.\n\tMakeClient(trustURLs bool) *http.Client\n\n\t// MakeTransport returns a RoundTripper that is suitable for making requests to external resources. The default\n\t// implementation provides:\n\t// - A shorter timeout for dial and TLS handshake (defined as constant \"ConnectTimeout\")\n\t// - A timeout for end-to-end requests\n\t// - A Mattermost-specific user agent header\n\t// - Additional security for untrusted and insecure connections\n\tMakeTransport(trustURLs bool) http.RoundTripper\n}\n```\nHTTPService wraps the functionality for making http requests to provide some improvements to the default client behaviour.\n\n```go\nfunc MakeHTTPService(configService configservice.ConfigService) HTTPService\n```\n\n```go\ntype HTTPServiceImpl struct {\n\tRequestTimeout time.Duration\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (h *HTTPServiceImpl) MakeClient(trustURLs bool) *http.Client\n```\n\n```go\nfunc (h *HTTPServiceImpl) MakeTransport(trustURLs bool) http.RoundTripper\n```\n\n```go\ntype MattermostTransport struct {\n\t// Transport is the underlying http.RoundTripper that is actually used to make the request\n\tTransport http.RoundTripper\n}\n```\nMattermostTransport is an implementation of http.RoundTripper that ensures each request contains a custom user agent string to indicate that the request is coming from a Mattermost instance.\n\n```go\nfunc (t *MattermostTransport) RoundTrip(req *http.Request) (*http.Response, error)\n```\n\n","path":"github.com/nmintoh/dserver/services/httpservice","name":"httpservice","synopsis":"","isRedistributable":true}
