Documentation
¶
Overview ¶
Package rest provides the basis of a restful http service.
Index ¶
- Constants
- type Config
- func (c Config) AllowedHeaders() []string
- func (c Config) AllowedMethods() []string
- func (c Config) AllowedOrigins() []string
- func (c Config) LogLevel() string
- func (c Config) MTLSEnabled() bool
- func (c Config) PProfEnabled() bool
- func (c Config) ServerAddr() string
- func (c Config) TLSCACert() string
- func (c Config) TLSCert() string
- func (c Config) TLSKey() string
- type Constructors
- type Server
Constants ¶
const (
DefaultLogLevel = "info"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds the configuration information for the restful api server.
func (Config) AllowedHeaders ¶
AllowedHeaders returns a string of Allowed Headers passed to the CORS middleware.
func (Config) AllowedMethods ¶
AllowedMethods returns a string of Allowed Methods passed to the CORS middleware.
func (Config) AllowedOrigins ¶
AllowedOrigins returns a string of Allowed Origins passed to the CORS middleware.
func (Config) MTLSEnabled ¶
MTLSEnabled returns true if MTLS is enabled.
func (Config) PProfEnabled ¶
PProfEnabled adds the pprof endpoints to the server.
func (Config) ServerAddr ¶
ServerAddr returns the network address the server will listen on.
type Constructors ¶
type Constructors struct {
NewConfig func(...string) (Config, error)
NewLogger func(Config) (*zerolog.Logger, error)
NewHTTPServer func(context.Context, Config) (*server.Server, error)
}
Constructors provide a way to inject different functions to create server components.
type Server ¶
type Server struct {
Stdout, Stderr io.Writer // Provides a way for unit tests to capture output to standard file descriptors.
C Constructors // Provides a way for unit tests to inject different object constructors.
// contains filtered or unexported fields
}
Server represents the restful api server.
func NewServer ¶
func NewServer(version, branch, commit, date string, mw ...mux.MiddlewareFunc) *Server
NewServer returns a new restful api server.