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 ...kitDefaults.ServerOption) GkBootOption
- func WithLogger(logger logging.Logger) 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
- func WithTLSConfig(cert, key string) GkBootOption
- type TLSConfig
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 // 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 []kitDefaults.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 // TLS configures the TLS settings for the REST service. TLS TLSConfig }
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 ...kitDefaults.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 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
func WithTLSConfig ¶ added in v1.3.0
func WithTLSConfig(cert, key string) GkBootOption
WithTLSConfig sets the TLS configuration for the BootConfig. The TLS configuration includes server certificate and key. This option is used by gkBoot to build the REST service with TLS enabled.
type TLSConfig ¶ added in v1.3.0
type TLSConfig struct {
// contains filtered or unexported fields
}
TLSConfig
Represents the TLS configuration for the REST service.
Fields: - serverCert: The server certificate file path or content. - serverKey: The server key file path or content.
Usage Example:
tls := TLSConfig{ serverCert: "/path/to/server.crt", serverKey: "/path/to/server.key", } bootConfig := BootConfig{ TLS: tls, }