Skip to content

Commit

Permalink
refactor: get rid of viper
Browse files Browse the repository at this point in the history
  • Loading branch information
heilmela committed Oct 29, 2023
1 parent a53c77d commit 21e8d81
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 576 deletions.
8 changes: 4 additions & 4 deletions cmd/livekit-events/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,26 @@ func run() error {

handler := srv.ServeHTTP

if len(config.ServerConfig.TrustedUpstream) > 0 {
if len(config.Server.TrustedUpstream) > 0 {
wrappedHandler := srv.TrustUpstream(http.HandlerFunc(handler))
router.HandleFunc("/webhook", wrappedHandler.ServeHTTP).Methods("POST")
} else {
router.HandleFunc("/webhook", handler).Methods("POST")
}
if config.RedisConfig != nil {
if config.Redis != nil {
if err := srv.StartRedisPublisher(); err != nil {
logger.Error("failed to start redis publisher")
return err
}
}

server := &http.Server{
Addr: fmt.Sprintf("%s:%v", config.ServerConfig.BindAddresse, config.ServerConfig.Port),
Addr: fmt.Sprintf("%s:%v", config.Server.BindAddress, config.Server.Port),
ReadHeaderTimeout: 5 * time.Second,
Handler: router,
}

logger.Sugar().Infof("started on %s:%v", config.ServerConfig.BindAddresse, config.ServerConfig.Port)
logger.Sugar().Infof("started on %s:%v", config.Server.BindAddress, config.Server.Port)
err = server.ListenAndServe()

return err
Expand Down
22 changes: 9 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ module github.com/heilmela/livekit-events
go 1.20

require (
github.com/spf13/viper v1.17.0
github.com/kelseyhightower/envconfig v1.4.0
go.uber.org/automaxprocs v1.5.3
go.uber.org/zap v1.26.0
)

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/frostbyte73/core v0.0.9 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gammazero/deque v0.2.1 // indirect
Expand All @@ -20,20 +22,14 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/twitchtv/twirp v8.1.3+incompatible // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.uber.org/atomic v1.11.0 // indirect
Expand All @@ -45,8 +41,8 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
Loading

0 comments on commit 21e8d81

Please sign in to comment.