mirror of
https://github.com/openfaas/faas.git
synced 2025-06-29 18:23:26 +00:00
Implement log proxy handler
**What** - Implement log handler method that will hijack the connection and clear timeouts to allow long lived streams - Proxies requests to the logs provider and returns the response unmodified Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
3c4077f3df
commit
e7e91ecd15
@ -31,4 +31,7 @@ type HandlerSet struct {
|
||||
|
||||
// SecretHandler allows secrets to be managed
|
||||
SecretHandler http.HandlerFunc
|
||||
|
||||
// LogProxyHandler allows streaming of logs for functions
|
||||
LogProxyHandler http.HandlerFunc
|
||||
}
|
||||
|
@ -72,6 +72,16 @@ func (ReadConfig) Read(hasEnv HasEnv) GatewayConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if len(hasEnv.Getenv("logs_provider_url")) > 0 {
|
||||
var err error
|
||||
cfg.LogsProviderURL, err = url.Parse(hasEnv.Getenv("logs_provider_url"))
|
||||
if err != nil {
|
||||
log.Fatal("If logs_provider_url is provided, then it should be a valid URL.", err)
|
||||
}
|
||||
} else if cfg.FunctionsProviderURL != nil {
|
||||
cfg.LogsProviderURL, _ = url.Parse(cfg.FunctionsProviderURL.String())
|
||||
}
|
||||
|
||||
faasNATSAddress := hasEnv.Getenv("faas_nats_address")
|
||||
if len(faasNATSAddress) > 0 {
|
||||
cfg.NATSAddress = &faasNATSAddress
|
||||
@ -158,6 +168,9 @@ type GatewayConfig struct {
|
||||
// URL for alternate functions provider.
|
||||
FunctionsProviderURL *url.URL
|
||||
|
||||
// URL for alternate function logs provider.
|
||||
LogsProviderURL *url.URL
|
||||
|
||||
// Address of the NATS service. Required for async mode.
|
||||
NATSAddress *string
|
||||
|
||||
|
Reference in New Issue
Block a user