Documentation ¶
Overview ¶
Package cobrahttp implements a builder for registering flags and producing a Cobra RunFunc that configures an HTTP server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to configure an HTTP server via Cobra.
func (*Builder) ListenFromFlags ¶
ListenFromFlags listens on the provided HTTP server using values configured in the provided command.
func (*Builder) RegisterFlags ¶
RegisterFlags adds flags for configuring an HTTP server.
The following flags are added: - "$PREFIX-addr" - "$PREFIX-tls-cert-path" - "$PREFIX-tls-key-path" - "$PREFIX-enabled"
type Option ¶
type Option func(b *Builder)
Option is function used to configure an HTTP server within a Cobra RunFunc.
func WithDefaultAddress ¶
WithDefaultAddress configures the default value of the address the server will listen at.
Defaults to ":8443"
func WithDefaultEnabled ¶
WithDefaultEnabled defines whether the server is enabled by default.
Defaults to "false".
func WithFlagPrefix ¶
WithFlagPrefix defines prefix used with the generated flags.
Defaults to "http".
func WithHandler ¶
WithHandler defines the handler used by the http.Server.
No handler is set by default.
func WithLogger ¶
WithLogger configures logging of the configured HTTP server environment.
func WithPreRunLevel ¶
WithPreRunLevel defines the logging level used for pre-run log messages.
Defaults to "debug".