confighttp

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 6 Imported by: 210

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClientSettings

type HTTPClientSettings struct {
	// The target URL to send data to (e.g.: http://some.url:9411/v1/trace).
	Endpoint string `mapstructure:"endpoint"`

	// TLSSetting struct exposes TLS client configuration.
	TLSSetting configtls.TLSClientSetting `mapstructure:",squash"`

	// Timeout parameter configures `http.Client.Timeout`.
	Timeout time.Duration `mapstructure:"timeout,omitempty"`
}

func (*HTTPClientSettings) ToClient

func (hcs *HTTPClientSettings) ToClient() (*http.Client, error)

type HTTPServerSettings

type HTTPServerSettings struct {
	// Endpoint configures the listening address for the server.
	Endpoint string `mapstructure:"endpoint"`

	// TLSSetting struct exposes TLS client configuration.
	TLSSetting *configtls.TLSServerSetting `mapstructure:"tls_settings, omitempty"`

	// CorsOrigins are the allowed CORS origins for HTTP/JSON requests to grpc-gateway adapter
	// for the OTLP receiver. See github.com/rs/cors
	// An empty list means that CORS is not enabled at all. A wildcard (*) can be
	// used to match any origin or one or more characters of an origin.
	CorsOrigins []string `mapstructure:"cors_allowed_origins"`
}
Example
settings := HTTPServerSettings{
	Endpoint: ":443",
}
s := settings.ToServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}))
l, err := settings.ToListener()
if err != nil {
	panic(err)
}
if err = s.Serve(l); err != nil {
	panic(err)
}
Output:

func (*HTTPServerSettings) ToListener

func (hss *HTTPServerSettings) ToListener() (net.Listener, error)

func (*HTTPServerSettings) ToServer

func (hss *HTTPServerSettings) ToServer(handler http.Handler) *http.Server

Directories

Path Synopsis
xconfighttp module

Jump to

Keyboard shortcuts

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