Documentation
¶
Index ¶
- func AddFlags(v *viper.Viper, f *pflag.FlagSet, hooks ...config.EncodeHookFunc) error
- func DecodeJSON(req *http.Request, obj interface{}) error
- func NewClient(cfg *ClientConfig) (*http.Client, error)
- func NewTransport(cfg *TransportConfig) (*http.Transport, error)
- func OverrideURL(dst, src *url.URL)
- func UnmarshalQuery(params url.Values, obj interface{}) error
- func WithBaseURL(baseURL *url.URL) autorest.PrepareDecorator
- func WriteError(rw http.ResponseWriter, statusCode int, err error)
- func WriteJSON(rw http.ResponseWriter, statusCode int, data interface{}) error
- type ClientConfig
- type Entrypoint
- func (ep *Entrypoint) Addr() string
- func (ep *Entrypoint) Ready(_ context.Context) error
- func (ep *Entrypoint) Server() *http.Server
- func (ep *Entrypoint) SetHandler(handler http.Handler)
- func (ep *Entrypoint) Start(ctx context.Context) error
- func (ep *Entrypoint) Stop(stopCtx context.Context) error
- type EntrypointConfig
- type EntrypointOption
- type ErrorRespMsg
- type KeepAliveProbeConfig
- type ListenConfig
- type ServerConfig
- type TLSCertConfig
- type TransportConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFlags ¶
AddFlags adds flags to the given viper and pflag.FlagSet. Sets - all viper keys with "ep." prefix - all environment variables with "EP_" prefix - all flags with "ep-" prefix
func DecodeJSON ¶
DecodeJSON decodes a JSON request body into the given object
func NewClient ¶
func NewClient(cfg *ClientConfig) (*http.Client, error)
New creates a new HTTP client
func NewTransport ¶
func NewTransport(cfg *TransportConfig) (*http.Transport, error)
NewTransport creates a new http.Transport
func OverrideURL ¶
OverrideURL overrides the destination URL with the source URL.
func UnmarshalQuery ¶
UnmarshalQuery unmarshals a URL query into the given object
func WithBaseURL ¶
func WithBaseURL(baseURL *url.URL) autorest.PrepareDecorator
WithBaseURL returns a PrepareDecorator that populates the http.Request with a url.URL constructed from the supplied baseUrl. Query parameters will be encoded as required.
func WriteError ¶
func WriteError(rw http.ResponseWriter, statusCode int, err error)
WriteError writes an error response with the given status code and error
Types ¶
type ClientConfig ¶
type ClientConfig struct {
Transport *TransportConfig `json:"transport,omitempty"`
Timeout *comtime.Duration `json:"timeout,omitempty"`
}
Config for creating an HTTP Client
func (*ClientConfig) SetDefault ¶
func (cfg *ClientConfig) SetDefault() *ClientConfig
type Entrypoint ¶
type Entrypoint struct {
*svc.RunContext
// contains filtered or unexported fields
}
Entrypoint listens on a local network address and serves incoming HTTP requests.
func NewEntrypoint ¶
func NewEntrypoint(addr string, opts ...EntrypointOption) (*Entrypoint, error)
NewEntrypoint creates a new Entrypoint.
func (*Entrypoint) Addr ¶
func (ep *Entrypoint) Addr() string
Addr returns the address the entrypoint is exposed to after Start() is called.
func (*Entrypoint) Ready ¶
func (ep *Entrypoint) Ready(_ context.Context) error
Ready returns the error from Serve(...) if it's not nil.
func (*Entrypoint) Server ¶ added in v0.6.1
func (ep *Entrypoint) Server() *http.Server
func (*Entrypoint) SetHandler ¶
func (ep *Entrypoint) SetHandler(handler http.Handler)
SetHandler sets the handler for the entrypoint.
type EntrypointConfig ¶
type EntrypointConfig struct {
Addr *string `key:"addr,omitempty" desc:"TCP Address to listen on"`
HTTP *ServerConfig `key:"http,omitempty"`
Net *ListenConfig `key:"net,omitempty"`
TLS *TLSCertConfig `key:"tls,omitempty"`
}
EntrypointConfig is the configuration for an entrypoint.
func DefaultEntrypointConfig ¶
func DefaultEntrypointConfig() *EntrypointConfig
DefaultEntrypointConfig returns a default EntrypointConfig.
func (*EntrypointConfig) Entrypoint ¶
func (cfg *EntrypointConfig) Entrypoint() (*Entrypoint, error)
func (*EntrypointConfig) Env ¶
func (cfg *EntrypointConfig) Env(hooks ...config.EncodeHookFunc) (map[string]string, error)
Env returns the environment variables for the entrypoint config. All environment variables are prefixed with "EP_".
func (*EntrypointConfig) MarshalJSON ¶ added in v0.9.1
func (cfg *EntrypointConfig) MarshalJSON() ([]byte, error)
type EntrypointOption ¶
type EntrypointOption func(*Entrypoint) error
func WithListenConfig ¶
func WithListenConfig(lCfg *net.ListenConfig) EntrypointOption
WithListenConfig sets the net.ListenConfig to use for the entrypoint.
func WithServer ¶
func WithServer(srv *http.Server) EntrypointOption
WithServer sets the http.Server to use for the entrypoint.
func WithTLSConfig ¶
func WithTLSConfig(tlsCfg *TLSCertConfig) EntrypointOption
WithTLSConfig sets the tls.Config to use for the entrypoint.
type ErrorRespMsg ¶
type ErrorRespMsg struct {
Message string `json:"message" example:"error message"`
Code string `json:"status,omitempty" example:"IR001"`
} // @name Error
ErrorRespMsg is a struct representing an error response message
type KeepAliveProbeConfig ¶
type KeepAliveProbeConfig struct {
Enable *bool `key:"enable,omitempty" desc:"Enable keep alive probes"`
Idle *time.Duration `key:"idle,omitempty" desc:"Time that the connection must be idle before the first keep-alive probe is sent"`
Interval *time.Duration `key:"interval,omitempty" desc:"Time between keep-alive probes"`
Count *int `key:"count,omitempty" desc:"Maximum number of keep-alive probes that can go unanswered before dropping a connection"`
}
func (*KeepAliveProbeConfig) KeepAliveProbe ¶
func (cfg *KeepAliveProbeConfig) KeepAliveProbe() *net.KeepAliveConfig
func (*KeepAliveProbeConfig) MarshalJSON ¶ added in v0.9.1
func (cfg *KeepAliveProbeConfig) MarshalJSON() ([]byte, error)
type ListenConfig ¶
type ListenConfig struct {
KeepAlive *time.Duration `` /* 137-byte string literal not displayed */
KeepAliveProbe *KeepAliveProbeConfig `key:"keepAliveProbe,omitempty" env:"KEEP_ALIVE_PROBE" flag:"keep-alive-probe"`
}
func (*ListenConfig) ListenConfig ¶
func (cfg *ListenConfig) ListenConfig() *net.ListenConfig
func (*ListenConfig) MarshalJSON ¶ added in v0.9.1
func (cfg *ListenConfig) MarshalJSON() ([]byte, error)
type ServerConfig ¶
type ServerConfig struct {
ReadTimeout *time.Duration `` /* 164-byte string literal not displayed */
ReadHeaderTimeout *time.Duration `` /* 176-byte string literal not displayed */
WriteTimeout *time.Duration `` /* 158-byte string literal not displayed */
IdleTimeout *time.Duration `` /* 186-byte string literal not displayed */
MaxHeaderBytes *int `` /* 202-byte string literal not displayed */
}
func (*ServerConfig) MarshalJSON ¶ added in v0.9.1
func (cfg *ServerConfig) MarshalJSON() ([]byte, error)
func (*ServerConfig) Server ¶
func (cfg *ServerConfig) Server() *http.Server
type TLSCertConfig ¶ added in v0.6.0
type TLSCertConfig struct {
CertFile *string `key:"certFile,omitempty" env:"CERT_FILE" desc:"Path to the certificate file"`
KeyFile *string `key:"keyFile,omitempty" env:"KEY_FILE" desc:"Path to the key file"`
}
func (*TLSCertConfig) MarshalJSON ¶ added in v0.9.1
func (cfg *TLSCertConfig) MarshalJSON() ([]byte, error)
type TransportConfig ¶
type TransportConfig struct {
Dialer *comnet.DialerConfig
IdleConnTimeout *comtime.Duration
ResponseHeaderTimeout *comtime.Duration
ExpectContinueTimeout *comtime.Duration
MaxIdleConnsPerHost int
MaxConnsPerHost int
DisableKeepAlives bool
DisableCompression bool
EnableHTTP2 bool
}
TransportConfig is a configuration for http.Transport
func (*TransportConfig) SetDefault ¶
func (cfg *TransportConfig) SetDefault() *TransportConfig
SetDefault sets default values for TransportConfig