Documentation
¶
Index ¶
- type BootConfig
- type GkBootOption
- func WithCustomConfig(cfg interface{}) GkBootOption
- func WithDatabase(db *sql.DB) GkBootOption
- func WithHttpPort(port int) GkBootOption
- func WithHttpServerOpts(opts ...httpTransport.ServerOption) GkBootOption
- func WithLogger(logger logging.Logger) GkBootOption
- func WithMetricsPath(path string) GkBootOption
- func WithOpenMetrics() GkBootOption
- func WithRootPath(path string) GkBootOption
- func WithServiceDecorator(decorator func(handler http.Handler) http.Handler) GkBootOption
- func WithServiceWrapper(wrapper service.Wrapper) GkBootOption
- func WithStrictAPI() GkBootOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BootConfig ¶
type BootConfig struct { // HttpPort // // Default value: 8080 // // Port that the http REST service runs on HttpPort *int // Logger // // Default value: valid JSON gkBoot.Logger // // The core logging subsystem. Each service is wrapped with this and the output is // deferred to the end of each call. Logger logging.Logger // CustomConfig // // Default value: nil // // A custom configuration. This is passed to each gkBoot.ConfigurableService. CustomConfig interface{} // Database // // Default value: nil // // A sql database. This is passed to each gkBoot.DatabaseConfigurable gkBoot.Service. Database *sql.DB // MetricsPath // // Default value: /metrics // // The path which surfaces metrics. This is used during wiring only if one service // implements gkBoot.Metered MetricsPath *string // EnableOpenMetrics // // Default value: false // // This is a toggle for OpenMetrics used in prometheus library. This is used during // wiring only if one service implements gkBoot.Metered EnableOpenMetrics bool // RootPath // // Default value: / // // The path for the root. All gkBoot.HttpRequest are relative to this path. RootPath *string // HttpOpts // // Default value: [] // // A set of http.ServerOption used when constructing route of each service. This is // attached to each service passed to gkBoot.GkBoot HttpOpts []httpTransport.ServerOption // ServiceWrappers // // Default value: [] // // A set of gkBoot.Wrapper used when constructing the services themselves. These // wrappers will be applied in the order encountered in the array. Every invocation of // WithServiceWrapper will add a new wrapper to wrap around every wired service. // // The wrapping algorithm will traverse a service tree, following the // service.UpdatableWrappedService GetNext function. To prevent wrapping of lower tier // protected delegates, do not implement service.UpdatableWrappedService on the owner of the delegate. ServiceWrappers []service.Wrapper // Decorators // // Default value: [] // // A set of functions that will wrap the primary handler of all requests. This can be used for global // functionality that must happen on every request (related to the http.Handler). // // Not to be confused with service.Wrapper, which has a more direct business logic domain. // The service.Wrapper can check for and respond to the interfaces implemented on the service, // whereas Decorators cannot. Decorators []func(handler http.Handler) http.Handler // StrictOpenAPI // // Default value: false // // When true, all wired services must implement service.OpenAPICompatible interface and all // responses from the service must be declared in service.OpenAPICompatible ExpectedResponses function StrictOpenAPI bool }
BootConfig
Used by gkBoot.GkBoot to build the REST service. Each option has a default value.
type GkBootOption ¶
type GkBootOption func(config *BootConfig)
GkBootOption
Option type used during wiring.
func WithCustomConfig ¶
func WithCustomConfig(cfg interface{}) GkBootOption
WithCustomConfig
Set the custom config used by each gkBoot.ConfigurableService
func WithDatabase ¶
func WithDatabase(db *sql.DB) GkBootOption
WithDatabase
Set a common database used and shared by all services
func WithHttpPort ¶
func WithHttpPort(port int) GkBootOption
WithHttpPort
Set the http port of the server
func WithHttpServerOpts ¶
func WithHttpServerOpts(opts ...httpTransport.ServerOption) GkBootOption
WithHttpServerOpts
Set server options used by all services on every request
func WithLogger ¶
func WithLogger(logger logging.Logger) GkBootOption
WithLogger
Set a custom gkBoot.Logger that will be used by each service automatically on deferment
func WithMetricsPath ¶
func WithMetricsPath(path string) GkBootOption
WithMetricsPath
Set the path for the prometheus metrics on the http server
func WithOpenMetrics ¶
func WithOpenMetrics() GkBootOption
WithOpenMetrics
Set the toggle to true for using OpenMetrics with prometheus
func WithRootPath ¶
func WithRootPath(path string) GkBootOption
WithRootPath
Set the root path of the http server for the REST endpoint
func WithServiceDecorator ¶
func WithServiceDecorator(decorator func(handler http.Handler) http.Handler) GkBootOption
WithServiceDecorator
Uses the given decorator wrap all service requests in a handler chain. Useful for things like global CORS implementation rules. The decorator will wrap all requests.
func WithServiceWrapper ¶
func WithServiceWrapper(wrapper service.Wrapper) GkBootOption
WithServiceWrapper
Appends the given service.Wrapper to the end of the service wrappers chain. The service wrappers are executed at the tail end of the service construction for each service. It may be necessary to include a type check.
func WithStrictAPI ¶
func WithStrictAPI() GkBootOption
WithStrictAPI
When used, all services must implement service.OpenAPICompatible interface and all responses from the service must be declared in service.OpenAPICompatible ExpectedResponses function