Documentation ¶
Index ¶
- Constants
- Variables
- func AddCommandLineFlags(result *Config)
- func AddFlagsToFlagSet(result *Config, flagSet *flag.FlagSet)
- func CreateTLSConfig(config TLSConfig) (*tls.Config, error)
- type Config
- type Handler
- type Metrics
- type MetricsRegistry
- type Request
- type ResponseWriter
- type Server
- type TLSConfig
Constants ¶
const HeaderContentType = "Content-type"
HeaderContentType denotes the header key to be used to send the content type
const HeaderTraceID = "X-Trace-Id"
Variables ¶
var HealthzResponse = []byte("he's not dead, jim")
HealthzResponse is the response to be returned when requesting the health of the server
Functions ¶
func AddCommandLineFlags ¶
func AddCommandLineFlags(result *Config)
AddCommandLineFlags adds all flags to flag.CommandLine for parsing the provided Config, using it's values as default
func AddFlagsToFlagSet ¶
AddFlagsToFlagSet works like AddCommandLineFlags but let's you specify the target flag.FlagSet
Types ¶
type Config ¶
type Config struct { // ServerNamespace is a name for the server to be used as namespace for the prometheus Metrics ServerNamespace string // Addr is the address to listen to Addr string // TLSConfig denotes the TLSConfig to be used TLSConfig TLSConfig // ReadTimeout denotes the timeout for reading the complete request ReadTimeout time.Duration // ReadHeaderTimeout denotes the timeout for reading the headers ReadHeaderTimeout time.Duration // WriteTimeout denotes the timeout for writing the complete response WriteTimeout time.Duration // IdleTimeout denotes the timeout for an idling request IdleTimeout time.Duration // MaxHeaderBytes denotes the maximum acceptable size of the request header in bytes MaxHeaderBytes int }
Config denotes the configuration parameters for Server
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig returns a new Config with the default options set
type Handler ¶
type Handler func(writer ResponseWriter, request *Request)
Handler is a function which handles the decorated ResponseWriter and Request
type Metrics ¶
type Metrics interface { // Requests provides the metering.Summary for the http requests Requests() metering.Summary }
Metrics provides access the http metrics
type MetricsRegistry ¶
type MetricsRegistry interface { metering.MetricsRegistry // HTTP provides the Metrics for the http subsystem HTTP() Metrics }
MetricsRegistry extends metering.MetricsRegistry for accessing HTTP metrics
type Request ¶
Request is a decorator for http.Request
func (*Request) ReadBodyAsJSON ¶
ReadBodyAsJSON will try to read the body as JSON into the provided object
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter // SendResponse sends a response with status code handling internal errors SendResponse(statusCode int, body []byte) // SendResponseString sends a string response SendResponseString(statusCode int, body string) // SendJSON marshals the provided object to JSON SendJSON(statusCode int, obj interface{}) // SendJSONBytes sends a marshaled json object SendJSONBytes(statusCode int, body []byte) // HandleInternalError will handle error occurred sending http.StatusInternalServerError, also logging the error HandleInternalError(err error) // Status yields the sent status response Status() int }
ResponseWriter is a decorator for http.ResponseWriter
type Server ¶
type Server struct { *http.Server *http.ServeMux Metrics MetricsRegistry // contains filtered or unexported fields }
Server is an extended http.Server
type TLSConfig ¶
type TLSConfig struct { // MinVersion is the minimum version string (e.g. 1.2) MinVersion string // CaCertsFile is the path to the CA certificates file to be used CaCertsFile string // PrivateKeyFile is the key file for the private key PrivateKeyFile string // PublicKeyFile is the key file for the public key PublicKeyFile string }
TLSConfig denotes the TLS configuration for Server