package http import ( "time" "forge.cadoles.com/arcad/edge/pkg/app" "forge.cadoles.com/arcad/edge/pkg/bus" "forge.cadoles.com/arcad/edge/pkg/bus/memory" "github.com/igm/sockjs-go/v3/sockjs" ) type HandlerOptions struct { Bus bus.Bus SockJS sockjs.Options BackendModuleFactories []app.BackendModuleFactory } func defaultHandlerOptions() *HandlerOptions { sockjsOptions := func() sockjs.Options { return sockjs.DefaultOptions }() sockjsOptions.DisconnectDelay = 10 * time.Second return &HandlerOptions{ Bus: memory.NewBus(), SockJS: sockjsOptions, BackendModuleFactories: make([]app.BackendModuleFactory, 0), } } type HandlerOptionFunc func(*HandlerOptions) func WithBackendModules(factories ...app.BackendModuleFactory) HandlerOptionFunc { return func(opts *HandlerOptions) { opts.BackendModuleFactories = factories } } func WithSockJS(options sockjs.Options) HandlerOptionFunc { return func(opts *HandlerOptions) { opts.SockJS = options } } func WithBus(bus bus.Bus) HandlerOptionFunc { return func(opts *HandlerOptions) { opts.Bus = bus } }