rhttp

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHTTPClient

func GetHTTPClient(opts ...Option) *http.Client

GetHTTPClient returns an http client with open census tracing support. TODO(labkode): harden it. https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779

func InitServices added in v1.25.0

func InitServices(ctx context.Context, services map[string]config.ServicesConfig) (map[string]global.Service, error)

func NewRequest

func NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

NewRequest creates an HTTP request that sets the token if it is passed in ctx.

Types

type Config added in v1.25.0

type Config func(*Server)

func WithCertAndKeyFiles added in v1.25.0

func WithCertAndKeyFiles(cert, key string) Config

func WithLogger added in v1.25.0

func WithLogger(log zerolog.Logger) Config

func WithMiddlewares added in v1.25.0

func WithMiddlewares(middlewares []global.Middleware) Config

func WithServices added in v1.25.0

func WithServices(services map[string]global.Service) Config

type Option added in v0.0.2

type Option func(o *Options)

Option defines a single option function.

func Context added in v0.0.2

func Context(val context.Context) Option

Context provides a function to set the context option.

func DisableKeepAlive added in v0.0.2

func DisableKeepAlive(disable bool) Option

DisableKeepAlive provides a function to set the disablee keep alive option.

func Insecure added in v0.0.2

func Insecure(insecure bool) Option

Insecure provides a function to set the insecure option.

func Timeout added in v0.0.2

func Timeout(t time.Duration) Option

Timeout provides a function to set the timeout option.

type Options added in v0.0.2

type Options struct {
	Context          context.Context
	Timeout          time.Duration
	Insecure         bool
	DisableKeepAlive bool
}

Options defines the available options for this package.

type Server

type Server struct {
	Services map[string]global.Service // map key is service name
	CertFile string
	KeyFile  string
	// contains filtered or unexported fields
}

Server contains the server info.

func New

func New(c ...Config) (*Server, error)

New returns a new server.

func (*Server) Address

func (s *Server) Address() string

Address returns the network address.

func (*Server) GracefulStop

func (s *Server) GracefulStop() error

GracefulStop gracefully stops the server.

func (*Server) Network

func (s *Server) Network() string

Network return the network type.

func (*Server) Start

func (s *Server) Start(ln net.Listener) error

Start starts the server.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the server.

Directories

Path Synopsis
Package datatx provides a library to abstract the complexity of using various data transfer protocols.
Package datatx provides a library to abstract the complexity of using various data transfer protocols.
utils/download
Package download provides a library to handle file download requests.
Package download provides a library to handle file download requests.

Jump to

Keyboard shortcuts

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