Documentation ¶
Overview ¶
Package web provides web based micro services
Index ¶
- Variables
- type Option
- func Action(a func(*cli.Context)) Option
- func Address(a string) Option
- func Advertise(a string) Option
- func AfterStart(fn func() error) Option
- func AfterStop(fn func() error) Option
- func BeforeStart(fn func() error) Option
- func BeforeStop(fn func() error) Option
- func Context(ctx context.Context) Option
- func Flags(flags ...cli.Flag) Option
- func HandleSignal(b bool) Option
- func Handler(h http.Handler) Option
- func Icon(ico string) Option
- func Id(id string) Option
- func Metadata(md map[string]string) Option
- func MicroService(s micro.Service) Option
- func Name(n string) Option
- func RegisterCheck(fn func(context.Context) error) Option
- func RegisterInterval(t time.Duration) Option
- func RegisterTTL(t time.Duration) Option
- func Registry(r registry.Registry) Option
- func Secure(b bool) Option
- func Server(srv *http.Server) Option
- func StaticDir(d string) Option
- func TLSConfig(t *tls.Config) Option
- func Version(v string) Option
- type Options
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // For serving DefaultName = "go-web" DefaultVersion = "latest" DefaultId = uuid.New().String() DefaultAddress = ":0" // for registration DefaultRegisterTTL = time.Second * 90 DefaultRegisterInterval = time.Second * 30 // static directory DefaultStaticDir = "html" DefaultRegisterCheck = func(context.Context) error { return nil } )
Web basic Defaults
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(o *Options)
Option for web
func AfterStart ¶
AfterStart is executed after server start.
func BeforeStart ¶
BeforeStart is executed before the server starts.
func BeforeStop ¶
BeforeStop is executed before the server stops.
func Context ¶
Context specifies a context for the service. Can be used to signal shutdown of the service. Can be used for extra option values.
func HandleSignal ¶
HandleSignal toggles automatic installation of the signal handler that traps TERM, INT, and QUIT. Users of this feature to disable the signal handler, should control liveness of the service through the context.
func MicroService ¶
func MicroService(s micro.Service) Option
MicroService sets the micro.Service used internally
func RegisterCheck ¶
RegisterCheck run func before registry service
func RegisterInterval ¶
RegisterInterval Register the service with at interval
func RegisterTTL ¶
RegisterTTL Register the service with a TTL
func Secure ¶
Secure Use secure communication. If TLSConfig is not specified we use InsecureSkipVerify and generate a self signed cert
type Options ¶
type Options struct { Name string Version string Id string Metadata map[string]string Address string Advertise string Action func(*cli.Context) Flags []cli.Flag RegisterTTL time.Duration RegisterInterval time.Duration // RegisterCheck runs a check function before registering the service RegisterCheck func(context.Context) error Server *http.Server Handler http.Handler // Alternative Options Context context.Context Registry registry.Registry Service micro.Service Secure bool TLSConfig *tls.Config BeforeStart []func() error BeforeStop []func() error AfterStart []func() error AfterStop []func() error // Static directory StaticDir string Signal bool }
Options for web