http_transport

package
v0.2.26 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTracingToHTTPClient

func ApplyTracingToHTTPClient(cli *http.Client)

ApplyTracingToHTTPClient propagate tracing.ID and X-Request-ID on exists http.Client.

func BasicAuthHandler added in v0.2.14

func BasicAuthHandler(next http.Handler, cfg BasicAuthConfig) http.Handler

func TracingMiddleware

func TracingMiddleware(handler http.Handler, opts ...otelhttp.Option) http.Handler

TracingMiddleware wraps the passed http.Handler, functioning like middleware, in a span named after the operation and with any provided Options.

func TracingMiddlewareFunc

func TracingMiddlewareFunc(handler http.HandlerFunc, opts ...otelhttp.Option) http.Handler

HTTPTracingMiddlewareFunc wraps the passed http.HandlerFunc, functioning like middleware, in a span named after the operation and with any provided Options.

Types

type BasicAuthConfig added in v0.2.14

type BasicAuthConfig struct {
	Enabled  bool   `default:"false" usage:"allows to enable basic auth"`
	Username string `usage:"auth username"`
	Password string `usage:"auth password"`
}

type Config

type Config struct {
	Enabled           bool   `default:"false" usage:"allows to enable http server" example:"true"`
	Address           string `default:":8080" validate:"required,hostname_port" usage:"HTTP server listen address" example:"localhost:9000"`
	Network           string `default:"tcp" validate:"required" usage:"HTTP server listen network: tpc/udp" example:"tcp"`
	NoTrace           bool   `yaml:"no_trace" default:"false" usage:"allows to disable tracing for HTTP server" example:"false"`
	ReadTimeout       int    `yaml:"read_timeout" default:"5" usage:"HTTP server read timeout in seconds" example:"5"`
	WriteTimeout      int    `yaml:"write_timeout" default:"10" usage:"HTTP server write timeout in seconds" example:"10"`
	IdleTimeout       int    `yaml:"idle_timeout" default:"60" usage:"HTTP server idle timeout in seconds" example:"60"`
	ReadHeaderTimeout int    `yaml:"read_header_timeout" default:"10" usage:"HTTP server read header timeout in seconds" example:"10"`
}

Config provides configuration for http server.

type HttpServer added in v0.2.13

type HttpServer struct {
	Config
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...Option) *HttpServer

NewServer creates http server.

func (HttpServer) Enabled added in v0.2.13

func (s HttpServer) Enabled() bool

Enabled returns is service enabled.

func (HttpServer) Name added in v0.2.13

func (s HttpServer) Name() string

Name returns name of http server.

func (*HttpServer) Start added in v0.2.13

func (s *HttpServer) Start(ctx context.Context) error

Start allows starting http server.

func (*HttpServer) Stop added in v0.2.13

func (s *HttpServer) Stop(ctx context.Context) error

Stop allows stop http server.

type Option

type Option func(*HttpServer)

Option allows customizing http component settings.

func WithConfig

func WithConfig(v Config) Option

WithConfig allows set custom http settings.

func WithHandler

func WithHandler(v http.Handler) Option

WithHandler allows set custom http.Handler value.

func WithIdleTimeout added in v0.2.26

func WithIdleTimeout(v int) Option

WithIdleTimeout allows set custom idle timeout value.

func WithLogger

func WithLogger(v logger.ExtendedLogger) Option

WithLogger allows set custom logger value.

func WithName

func WithName(v string) Option

WithName allows set custom http name value.

func WithReadHeaderTimeout added in v0.2.26

func WithReadHeaderTimeout(v int) Option

WithReadHeaderTimeout allows set custom read header timeout value.

func WithReadTimeout added in v0.2.26

func WithReadTimeout(v int) Option

WithReadTimeout allows set custom read timeout value.

func WithWriteTimeout added in v0.2.26

func WithWriteTimeout(v int) Option

WithWriteTimeout allows set custom write timeout value.

Jump to

Keyboard shortcuts

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