Skip to content

Commit

Permalink
Rename ServerOpts to Opts
Browse files Browse the repository at this point in the history
Avoid repitition of prefix `server` for the client.
  • Loading branch information
adityav-verma authored Jul 31, 2021
1 parent 0cc3db5 commit eed45c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

func main() {
server.StartServer(
server.ServerOpts{
server.Opts{
SentryDSN: os.Getenv("SENTRY_DSN"),
Addr: ":8295",
},
)
}
}0
12 changes: 6 additions & 6 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var (
buildTime string
)

// ServerOpts provide configuration options for the server.
type ServerOpts struct {
// Opts provide configuration options for the server.
type Opts struct {
SentryDSN string
Addr string
}
Expand Down Expand Up @@ -95,13 +95,13 @@ func setupRouter(ctx context.Context, logger *zerolog.Logger) (context.Context,
}

// StartServer starts the translate proxy server.
func StartServer(serverOpts ServerOpts) {
func StartServer(opts Opts) {
serverCtx, logger := setupLogger(context.Background())

// Setup Sentry.
if serverOpts.SentryDSN != "" {
if opts.SentryDSN != "" {
err := sentry.Init(sentry.ClientOptions{
Dsn: serverOpts.SentryDSN,
Dsn: opts.SentryDSN,
Release: fmt.Sprintf("go-sync@%s-%s", commit, buildTime),
})
if err != nil {
Expand All @@ -114,7 +114,7 @@ func StartServer(serverOpts ServerOpts) {

serverCtx, r := setupRouter(serverCtx, logger)

srv := http.Server{Addr: serverOpts.Addr, Handler: chi.ServerBaseContext(serverCtx, r)}
srv := http.Server{Addr: opts.Addr, Handler: chi.ServerBaseContext(serverCtx, r)}
err := srv.ListenAndServe()
if err != nil {
sentry.CaptureException(err)
Expand Down

0 comments on commit eed45c5

Please sign in to comment.