Files
ark/server/internal/interface/grpc/config.go
Pietralberto Mazza f9e7621165 Add grpc-gateway and /healthz endpoint (#133)
* Add grpc-gateway and /healthz endpoint

* Add nolint

* nosec
2024-04-19 17:11:59 +02:00

42 lines
636 B
Go

package grpcservice
import (
"crypto/tls"
"fmt"
"net"
)
type Config struct {
Port uint32
NoTLS bool
}
func (c Config) Validate() error {
lis, err := net.Listen("tcp", c.address())
if err != nil {
return fmt.Errorf("invalid port: %s", err)
}
defer lis.Close()
if !c.NoTLS {
return fmt.Errorf("tls termination not supported yet")
}
return nil
}
func (c Config) insecure() bool {
return c.NoTLS
}
func (c Config) address() string {
return fmt.Sprintf(":%d", c.Port)
}
func (c Config) gatewayAddress() string {
return fmt.Sprintf("localhost:%d", c.Port)
}
func (c Config) tlsConfig() *tls.Config {
return nil
}