add grpc server support

This commit is contained in:
yanghao05
2023-05-06 15:29:16 +08:00
parent 3a9a1a6eeb
commit 4964b59b2c
9 changed files with 156 additions and 35 deletions

View File

@@ -4,7 +4,7 @@ import (
"fmt"
)
const ConfigPrefix = "Http"
const DefaultPrefix = "Http"
type Config struct {
Static *string

View File

@@ -1,33 +0,0 @@
package http
import (
"log"
"github.com/spf13/viper"
)
const DefaultPrefix = "Http"
func AutoLoadConfig() *Config {
return LoadConfig("")
}
func LoadConfig(file string) *Config {
if file == "" {
file = "config.toml"
}
v := viper.NewWithOptions(viper.KeyDelimiter("_"))
v.AutomaticEnv()
v.SetConfigFile(file)
if err := v.ReadInConfig(); err != nil {
log.Fatal(err)
}
var config Config
if err := v.UnmarshalKey(DefaultPrefix, &config); err != nil {
log.Fatal(err)
}
return &config
}