http

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 5 Imported by: 0

README

http

Contains functions for managing HTTP requests. Substation follows these rules across every application:

  • HTTP clients are always retryable clients from this package
  • For AWS deployments, HTTP clients enable AWS X-Ray

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTP

type HTTP struct {
	Client *retryablehttp.Client
}

HTTP wraps a retryable HTTP client.

func (*HTTP) EnableXRay

func (h *HTTP) EnableXRay()

EnableXRay replaces the standard retryable HTTP client with an AWS XRay client. This method can be used when making HTTP calls on AWS infrastructure and should be enabled by looking for the environment variable "AWS_XRAY_DAEMON_ADDRESS".

func (*HTTP) Get

func (h *HTTP) Get(ctx context.Context, url string, headers ...Header) (*http.Response, error)

Get is a context-aware convenience function for making GET requests.

func (*HTTP) IsEnabled

func (h *HTTP) IsEnabled() bool

IsEnabled identifies if the HTTP client is enabled and ready to use. This method can be used for lazy loading the client.

func (*HTTP) Post

func (h *HTTP) Post(ctx context.Context, url string, payload interface{}, headers ...Header) (resp *http.Response, err error)

Post is a context-aware convenience function for making POST requests. This method optionally supports custom headers.

func (*HTTP) Setup

func (h *HTTP) Setup()

Setup creates a retryable HTTP client.

type Header struct {
	Key   string
	Value string
}

Header contains a single HTTP header that can be passed to HTTP.Post. Multiple headers can be passed to HTTP.Post as a slice.

Jump to

Keyboard shortcuts

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