Abstract HTTP server functional options
The github.com/go-nacelle/httpbase
package provides the following functional options to supply the server constructor.
WithTagModifiers
WithTagModifiers registers the tag modifiers to be used when loading the server’s configuration. This can be used to change default hosts and ports, or prefix all target environment variables in the case where more than one HTTP server is registered per application (e.g. health server and application server, data plane and control plane server).
1
2
3
4
5
6
7
8
9
10
11
12
| func setup(processes nacelle.ProcessContainer, services nacelle.ServiceContainer) error {
dataServerConfigFunc := // ...
metaServerConfigFunc := // ...
// Reads data_http_{host,port,cert_file,key_file,shutdown_timeout}
dataServer := httpbase.NewServer(dataServerConfigFunc, httpbase.WithTagModifiers(nacelle.NewEnvTagPrefixer("data")))
processes.RegisterProcess(dataServer)
// Reads meta_http_{host,port,cert_file,key_file,shutdown_timeout}
metaServer := httpbase.NewServer(metaServerConfigFunc, httpbase.WithTagModifiers(nacelle.NewEnvTagPrefixer("meta")))
processes.RegisterProcess(metaServer)
}
|