catalog-service/src/pkg/server/config.go
2024-04-17 19:14:07 +02:00

35 lines
556 B
Go

package server
import (
"fmt"
"net"
"os"
"time"
)
type Config struct {
AppID string
AppName string
AppDomain string
NetAddr string
PathPrefix string
IdleTimeout time.Duration // miliseconds
ReadTimeout time.Duration // miliseconds
WriteTimeout time.Duration // miliseconds
}
func (c *Config) GetAppFullName() string {
return fmt.Sprintf("%s_%s", c.AppName, c.AppID)
}
func (c *Config) GetIP() string {
host, _ := os.Hostname()
ips, _ := net.LookupIP(host)
for _, ip := range ips {
return ip.String()
}
return host
}