Documentation ¶
Overview ¶
Package web provides web based vine services
Index ¶
- Constants
- Variables
- type Option
- func Action(a func(*cobra.Command, []string)) Option
- func Address(a string) Option
- func Advertise(a string) Option
- func AfterStart(fn func() error) Option
- func AfterStop(fn func() error) Option
- func App(app *gin.Engine) Option
- func BeforeStart(fn func() error) Option
- func BeforeStop(fn func() error) Option
- func Context(ctx context.Context) Option
- func FlagSet(flagSet *pflag.FlagSet) Option
- func HandleSignal(b bool) Option
- func Icon(ico string) Option
- func Id(id string) Option
- func Metadata(md map[string]string) 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 StaticDir(d string) Option
- func TLSConfig(t *tls.Config) Option
- func Version(v string) Option
- func VineService(s vine.Service) Option
- type Options
- type Service
Constants ¶
const ( MethodGet = "GET" // RFC 7231, 4.3.1 MethodHead = "HEAD" // RFC 7231, 4.3.2 MethodPost = "POST" // RFC 7231, 4.3.3 MethodPut = "PUT" // RFC 7231, 4.3.4 MethodPatch = "PATCH" // RFC 5789 MethodDelete = "DELETE" // RFC 7231, 4.3.5 MethodConnect = "CONNECT" // RFC 7231, 4.3.6 MethodOptions = "OPTIONS" // RFC 7231, 4.3.7 MethodTrace = "TRACE" // RFC 7231, 4.3.8 MethodAny = "*" )
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 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
func VineService ¶
VineService sets the vine.Service used internally
type Options ¶
type Options struct { Name string Version string Id string Metadata map[string]string Address string Advertise string Action func(*cobra.Command, []string) FlagSet *pflag.FlagSet RegisterTTL time.Duration RegisterInterval time.Duration // RegisterCheck runs a check function before registering the service RegisterCheck func(context.Context) error App *gin.Engine // Alternative Options Context context.Context Registry registry.Registry Service vine.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