Skip to content

Commit b0eef05

Browse files
author
vcarvajal
committed
Add support for 'server_flavor' revproxy config option
1 parent f3023af commit b0eef05

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

config.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ var (
3333
DefaultTimeout = 100 * time.Millisecond
3434
// DefaultServerIdentifier is the default value
3535
DefaultServerIdentifier = runtime.Version()
36+
// DefaultServerFlavor is the default value
37+
DefaultServerFlavor = ""
3638
)
3739

3840
// HeaderExtractorFunc is a header extraction function
@@ -53,6 +55,7 @@ type ModuleConfig struct {
5355
rpcAddress string
5456
rpcNetwork string
5557
serverIdentifier string
58+
serverFlavor string
5659
timeout time.Duration
5760
}
5861

@@ -72,6 +75,7 @@ func NewModuleConfig(options ...ModuleConfigOption) (*ModuleConfig, error) {
7275
rpcAddress: DefaultRPCAddress,
7376
rpcNetwork: DefaultRPCNetwork,
7477
serverIdentifier: DefaultServerIdentifier,
78+
serverFlavor: DefaultServerFlavor,
7579
timeout: DefaultTimeout,
7680
}
7781
if err := c.SetOptions(options...); err != nil {
@@ -185,6 +189,11 @@ func (c *ModuleConfig) ServerIdentifier() string {
185189
return c.serverIdentifier
186190
}
187191

192+
// ServerFlavor returns the configuration value
193+
func (c *ModuleConfig) ServerFlavor() string {
194+
return c.serverFlavor
195+
}
196+
188197
// Timeout returns the configuration value
189198
func (c *ModuleConfig) Timeout() time.Duration {
190199
return c.timeout
@@ -335,6 +344,15 @@ func ServerIdentifier(id string) ModuleConfigOption {
335344
}
336345
}
337346

347+
// ServerFlavor is a function argument that sets the server
348+
// flavor for custom setups using revproxy.
349+
func ServerFlavor(serverModule string) ModuleConfigOption {
350+
return func(c *ModuleConfig) error {
351+
c.serverFlavor = serverModule
352+
return nil
353+
}
354+
}
355+
338356
// FromModuleConfig allow cloning the config
339357
func FromModuleConfig(mcfg *ModuleConfig) ModuleConfigOption {
340358
return func(c *ModuleConfig) error {

module.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func NewModule(h http.Handler, options ...ModuleConfigOption) (*Module, error) {
6363
in := RPCMsgIn{
6464
ModuleVersion: m.config.ModuleIdentifier(),
6565
ServerVersion: m.config.ServerIdentifier(),
66-
ServerFlavor: "",
66+
ServerFlavor: m.config.ServerFlavor(),
6767
Timestamp: now.Unix(),
6868
NowMillis: now.UnixNano() / 1e6,
6969
}

0 commit comments

Comments
 (0)