httpclient

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package httpclient contains custom implementation of a http client that let us perform actions against an external service allowed actions: GET, POST, DELETE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Get(request Request) (*Response, error)
	Post(request Request) (*Response, error)
	Delete(request Request) (*Response, error)
}

Client interface give us the flexibility to implement http client in different ways, so we can use a third party library or a custom client and switch between them with minimum efforts and impact.

func NewClient

func NewClient() Client

NewClient creates a new instance of a standardClient struct.

type ClientMock

type ClientMock struct {
	mock.Mock
}

func (ClientMock) Delete

func (mock ClientMock) Delete(request Request) (*Response, error)

func (ClientMock) Get

func (mock ClientMock) Get(request Request) (*Response, error)

func (ClientMock) Post

func (mock ClientMock) Post(request Request) (*Response, error)

type Request

type Request struct {
	Url     string
	Headers map[string]string
	Payload interface{}
}

Request contains the minimum information to perform an action against an external service

type Response

type Response struct {
	HttpStatus int
	Headers    http.Header
	Body       []byte
}

Response contains the information related to the external service's response.

Jump to

Keyboard shortcuts

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