http

package
v0.0.0-...-6d13c91 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

* Copyright 2020 The Compass Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const HeadersContextKey key = iota

Variables

This section is empty.

Functions

func HeaderForwarder

func HeaderForwarder(forwardHeaders []string) func(next http.Handler) http.Handler

HeaderForwarder stores the specified request headers in the context so that they can later be used and forwarded to other backends

func LoadFromContext

func LoadFromContext(ctx context.Context) (map[string]string, error)

func NewClient

func NewClient(timeout time.Duration, transport http.RoundTripper) *http.Client

func NewHTTPTransport

func NewHTTPTransport(config *Config) *http.Transport

func SaveToContext

func SaveToContext(ctx context.Context, key, val string) context.Context

func UnauthorizedMiddleware

func UnauthorizedMiddleware() func(next http.Handler) http.Handler

UnauthorizedMiddleware ensures that unauthorized responses are correctly propagated.

Types

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

type Config

type Config struct {
	Timeout               time.Duration `` /* 167-byte string literal not displayed */
	TLSHandshakeTimeout   time.Duration `mapstructure:"tls_handshake_timeout"`
	IdleConnTimeout       time.Duration `mapstructure:"idle_conn_timeout"`
	ResponseHeaderTimeout time.Duration `mapstructure:"response_header_timeout"`
	DialTimeout           time.Duration `mapstructure:"dial_timeout"`
	ExpectContinueTimeout time.Duration `mapstructure:"expect_continue_timeout"`

	MaxIdleConns      int  `mapstructure:"max_idle_cons"`
	SkipSSLValidation bool `mapstructure:"skip_ssl_validation" description:"whether to skip ssl verification when making calls to external services"`

	ForwardHeaders []string `mapstructure:"forward_headers"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Validate

func (s *Config) Validate() error

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Expiration  int64  `json:"expires_in"`
}

func (Token) EmptyOrExpired

func (token Token) EmptyOrExpired(tokenExpirationBuffer time.Duration) bool

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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