httpclient

package module
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 6 Imported by: 5

README

component-httpclient - Settings component for generate HTTP clients

GoDoc

Bugs Code Smells Coverage Lines of Code Maintainability Rating Quality Gate Status Reliability Rating Security Rating Technical Debt Vulnerabilities

autoauto- [component-httpclient - Settings component for generate HTTP clients](#component-httpclient---settings-component-for-generate-http-clients)auto - [Overview](#overview)auto - [Quick Start](#quick-start)auto - [Status](#status)auto - [Contributing](#contributing)auto - [Building And Testing](#building-and-testing)auto - [License](#license)auto - [Contributing Agreement](#contributing-agreement)autoauto

Overview

This is a settings component that enables constructing a simple HTTP client. Using SMART client from transportd configuration is no longer supported as we no longer maintain transportd as of January 2024.

Quick Start

package main

import (
    "context"
    "net/http"

    httpclient "github.com/asecurityteam/component-httpclient"
    "github.com/asecurityteam/settings/v2"
)

func main() {
    ctx := context.Background()
    envSource := settings.NewEnvSource(os.Environ())

    tr := httpclient.New(ctx, envSource)

    c := &http.Client{
        Transport: tr,
    }
}

Status

This project is in incubation which means we are not yet operating this tool in production and the interfaces are subject to change.

Contributing

Building And Testing

We publish a docker image called SDCLI that bundles all of our build dependencies. It is used by the included Makefile to help make building and testing a bit easier. The following actions are available through the Makefile:

  • make dep

    Install the project dependencies into a vendor directory

  • make lint

    Run our static analysis suite

  • make test

    Run unit tests and generate a coverage artifact

  • make integration

    Run integration tests and generate a coverage artifact

  • make coverage

    Report the combined coverage for unit and integration tests

License

This project is licensed under Apache 2.0. See LICENSE.txt for details.

Contributing Agreement

Atlassian requires signing a contributor's agreement before we can accept a patch. If you are an individual you can fill out the individual CLA. If you are contributing on behalf of your company then please fill out the corporate CLA.

Documentation

Index

Constants

View Source
const (
	// TypeDefault is used to select the default Go HTTP client.
	TypeDefault = "DEFAULT"
	// TypeSmart is used to select the transportd HTTP client.
	// Deprecated: TypeSmart is no longer available as we no longer maintain transportd
	TypeSmart = "SMART"
)

Variables

This section is empty.

Functions

func Load

func Load(ctx context.Context, source settings.Source, c *Component) (http.RoundTripper, error)

Load is a convenience method for binding the source to the component.

func New

func New(ctx context.Context, source settings.Source) (http.RoundTripper, error)

New is the top-level entry point for creating a new HTTP client. The default set of plugins will be installed for the smart client. Use the LoadHTTP() method if a custom set of plugins are required.

Types

type Component

type Component struct {
	Default *DefaultComponent
}

Component is the top level HTTP client component.

func NewComponent

func NewComponent() *Component

NewComponent populates an HTTPComponent with defaults.

func (*Component) New

func (c *Component) New(ctx context.Context, conf *Config) (http.RoundTripper, error)

New constructs a client from the given configuration.

func (*Component) Settings

func (c *Component) Settings() *Config

Settings returns the default configuration.

type Config

type Config struct {
	Type    string `description:"The type of HTTP client. Choices are SMART and DEFAULT."`
	Default *DefaultConfig
}

Config wraps all HTTP related settings.

func (*Config) Name

func (*Config) Name() string

Name of the config.

type DefaultComponent

type DefaultComponent struct{}

DefaultComponent is a component for creating the default Go HTTP client.

func (*DefaultComponent) New

New constructs a client from the given configuration

func (*DefaultComponent) Settings

func (*DefaultComponent) Settings() *DefaultConfig

Settings returns the default configuration.

type DefaultConfig

type DefaultConfig struct {
	ContentType string
}

DefaultConfig contains all settings for the default Go HTTP client.

type RoundTripper

type RoundTripper = http.RoundTripper

RoundTripper is the interface that handles all HTTP operations. It is almost exclusively used with an http.Client wrapped around it. This is included here for documentation purposes only.

Jump to

Keyboard shortcuts

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