Skip to content

Commit 076a557

Browse files
committed
fix: remove unneeded config values
1 parent cf415d1 commit 076a557

File tree

5 files changed

+4
-29
lines changed

5 files changed

+4
-29
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
build/
1+
build/
2+
.DS_Store

env/env.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
package env
22

33
import (
4-
"time"
5-
64
"github.com/caarlos0/env"
75
)
86

97
// Config represents the common environment variables needed for all apps.
108
type Config struct {
11-
AppName string `env:"APP_NAME,required"`
12-
TeamName string `env:"TEAM_NAME,required"`
13-
Environment string `env:"APP_ENV,required"`
14-
BuildDate time.Time `env:"BUILD_DATE"`
15-
BuildGitHash string `env:"BUILD_GIT_HASH,required"`
16-
BuildGitTag string `env:"BUILD_GIT_TAG,required"`
179
}
1810

1911
// Load will bind the environment variables to the given config.

logging/log.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ func Initialize(c env.Config) *zap.Logger {
2424
))
2525

2626
log = log.With(
27-
zap.String("app_name", c.AppName),
28-
zap.String("environment", c.Environment),
29-
zap.String("build_git_hash", c.BuildGitHash),
30-
zap.String("build_git_tag", c.BuildGitTag),
31-
zap.Time("build_date", c.BuildDate),
32-
zap.String("team", c.TeamName),
3327
zap.String("run_id", uuid.New().String()),
3428
zap.Time("start_time", time.Now()),
3529
)

main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ type config struct {
2222
env.Config
2323
ListenIPAddress string `env:"LISTEN_IP,required"`
2424
ListenPort int `env:"LISTEN_PORT,required"`
25-
CORSOrigin string `env:"CORS_ORIGIN,required"`
2625
WeeWxURL string `env:"WEEWX_URL,required"`
2726
}
2827

@@ -53,7 +52,7 @@ func main() {
5352

5453
h := handler.New(weewx.NewClient(c.WeeWxURL, log))
5554

56-
r := router.NewRouter(h, log, c.BuildGitTag, c.CORSOrigin)
55+
r := router.NewRouter(h, log)
5756

5857
err = startHTTPServer(r, log, fmt.Sprintf("%s:%d", c.ListenIPAddress, c.ListenPort))
5958
if err != nil {

router/router.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"net/http"
66

77
"github.com/go-chi/chi"
8-
"github.com/go-chi/cors"
98
"go.uber.org/zap"
109

1110
"github.com/darkdragonsastro/weewx-json-alpaca/middleware"
@@ -52,21 +51,11 @@ type Handler interface {
5251

5352
// NewRouter creates a new CORS enabled router for our API. All requests will be logged and
5453
// instrumented with New Relic.
55-
func NewRouter(h Handler, log *zap.Logger, version, corsOrigin string) http.Handler {
54+
func NewRouter(h Handler, log *zap.Logger) http.Handler {
5655
r := chi.NewRouter()
5756

58-
cors := cors.New(cors.Options{
59-
AllowedOrigins: []string{corsOrigin},
60-
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
61-
AllowedHeaders: []string{"*"},
62-
AllowCredentials: true,
63-
MaxAge: 300,
64-
})
65-
66-
r.Use(middleware.Version(version))
6757
r.Use(middleware.TraceID)
6858
r.Use(middleware.Logger(log))
69-
r.Use(cors.Handler)
7059
r.Use(middleware.Alpaca)
7160
r.NotFound(h.NotFound)
7261

0 commit comments

Comments
 (0)