externalapi

package
v0.0.0-...-4109721 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package externalapi provides functionality to do external calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(logger *slog.Logger) *http.Client

NewHTTPClient creates an http client with proper log for external request.

Types

type ExternalAPI

type ExternalAPI struct {
	URL        *url.URL
	HTTPClient *http.Client
	Timeout    time.Duration
}

ExternalAPI represents the API that we want to making call to.

func New

func New(apiURL *url.URL, httpClient *http.Client, timeout time.Duration) *ExternalAPI

New is the factory function to create an en external API that we want to interact with.

func (*ExternalAPI) Request

func (ex *ExternalAPI) Request(ctx context.Context, httpMethod string, body []byte, header http.Header) (*http.Response, error)

Request excutes a request to an external API.

Jump to

Keyboard shortcuts

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