handlers

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package handlers exports the Map and Proxy handlers, that can be imported by thirdd party packages to augment gcs-helper's behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler added in v3.2.10

func Handler(c Config, client *storage.Client, hc *http.Client) http.HandlerFunc

func Map

func Map(c Config, client *storage.Client) http.Handler

Map returns the map handler.

func Proxy

func Proxy(c Config, hc *http.Client) http.Handler

Proxy returns the proxy handler.

Types

type ClientConfig

type ClientConfig struct {
	Timeout         time.Duration `envconfig:"GCS_CLIENT_TIMEOUT" default:"2s"`
	IdleConnTimeout time.Duration `envconfig:"GCS_CLIENT_IDLE_CONN_TIMEOUT" default:"120s"`
	MaxIdleConns    int           `envconfig:"GCS_CLIENT_MAX_IDLE_CONNS" default:"10"`
	Credentials     *google.Credentials
}

ClientConfig contains configuration for the GCS client communication.

It contains options related to timeouts and keep-alive connections.

func (ClientConfig) HTTPClient

func (c ClientConfig) HTTPClient() (*http.Client, error)

HTTPClient returns an HTTP client with the proper authentication config (using Google's default application credentials) and timeouts.

type Config

type Config struct {
	Listen     string `default:":8080"`
	BucketName string `envconfig:"BUCKET_NAME" required:"true"`
	LogLevel   string `envconfig:"LOG_LEVEL" default:"debug"`
	Client     ClientConfig
	Map        MapConfig
	Proxy      ProxyConfig
}

Config represents the gcs-helper configuration that is loaded from the environment.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig loads the configuration from environment variables.

func (Config) Logger

func (c Config) Logger() *logrus.Logger

type MapConfig

type MapConfig struct {
	Endpoint    string `envconfig:"GCS_HELPER_MAP_PREFIX"`
	RegexFilter string `envconfig:"GCS_HELPER_MAP_REGEX_FILTER"`
}

MapConfig contains configuration for the map mode.

type ProxyConfig

type ProxyConfig struct {
	Endpoint     string        `envconfig:"GCS_HELPER_PROXY_PREFIX"`
	LogHeaders   []string      `envconfig:"GCS_HELPER_PROXY_LOG_HEADERS"`
	Timeout      time.Duration `envconfig:"GCS_HELPER_PROXY_TIMEOUT" default:"10s"`
	BucketOnPath bool          `envconfig:"GCS_HELPER_PROXY_BUCKET_ON_PATH"`
}

ProxyConfig contains configuration for the proxy mode.

Jump to

Keyboard shortcuts

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