service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	Name        string
	Method      string
	URI         string
	HandlerFunc http.HandlerFunc
	Decorators  []EndpointDecorator
}

type EndpointDecorator

type EndpointDecorator struct {
	Type          EndpointDecoratorType
	DecoratorFunc func(w http.ResponseWriter, r *http.Request)
}

func AfterDecorator

func AfterDecorator(df func(w http.ResponseWriter, r *http.Request)) EndpointDecorator

func BeforeDecorator

func BeforeDecorator(df func(w http.ResponseWriter, r *http.Request)) EndpointDecorator

type EndpointDecoratorType

type EndpointDecoratorType uint8
const (
	Before EndpointDecoratorType = iota
	After
)

type Option

type Option func(o *Options)

func AfterStart

func AfterStart(fn func() error) Option

func AfterStop

func AfterStop(fn func() error) Option

func BeforeStart

func BeforeStart(fn func() error) Option

func BeforeStop

func BeforeStop(fn func() error) Option

func Context

func Context(ctx context.Context) Option

func Port

func Port(p int) Option

func TLS

func TLS(certFile string, keyFile string) Option

type Options

type Options struct {
	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	Port            int
	CertificateFile string
	KeyFile         string
	Context         context.Context
	Signal          bool
	Sampler         sdktrace.Sampler
	Exporter        sdktrace.SpanExporter
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(name string, version string) (*Service, error)

func (*Service) Endpoints

func (s *Service) Endpoints(endpoints ...Endpoint) error

func (*Service) Init

func (s *Service) Init(opts ...Option) error

func (*Service) Name

func (s *Service) Name() string

func (*Service) Options

func (s *Service) Options() Options

func (*Service) Server

func (s *Service) Server() *server.HttpServer

func (*Service) Start

func (s *Service) Start(runInBackground bool) error

func (*Service) Stop

func (s *Service) Stop() error

func (*Service) String

func (s *Service) String() string

Jump to

Keyboard shortcuts

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