http_client

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

README

http_client

HTTP client implementation that provides standardized web request handling for external API communication.

Notes

  • Implements a reusable HTTP client for making external API requests
  • Handles common HTTP operations (GET, POST, etc.)
  • Includes proper error handling and request timeouts
  • Supports response parsing and deserialization
  • Provides a mock client implementation for testing
  • Follows Go's context patterns for request cancellation
  • Makes external service dependencies testable through interfaces
  • Implements proper connection management and reuse

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultHTTPClient

type DefaultHTTPClient struct{}

DefaultHTTPClient is the default implementation of HTTPClient.

func (*DefaultHTTPClient) Post

func (c *DefaultHTTPClient) Post(url, contentType string, body *bytes.Buffer) (*http.Response, error)

Post makes an HTTP POST request.

type HTTPClient

type HTTPClient interface {
	Post(url, contentType string, body *bytes.Buffer) (*http.Response, error)
}

HTTPClient is an interface for making HTTP requests.

func NewHTTPClient

func NewHTTPClient() HTTPClient

NewHTTPClient creates a new HTTPClient.

type MockHTTPClient

type MockHTTPClient struct {
	mock.Mock
}

MockHTTPClient is a mock implementation of HTTPClient.

func (*MockHTTPClient) Post

func (m *MockHTTPClient) Post(url, contentType string, body *bytes.Buffer) (*http.Response, error)

Post makes an HTTP POST request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL