diff options
| author | mo khan <mo@mokhan.ca> | 2025-03-13 10:04:25 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-03-13 10:04:25 -0600 |
| commit | 857af592cfa293b1cd6821c26a91e5a9be5bc19c (patch) | |
| tree | dd18fbcbb541761b44924ac04789c2a0f3ecf70c /cmd | |
| parent | d442b7707b35b3daea890b4d35a2a0d564abdd5c (diff) | |
refactor: extract WithRoutes config option
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/gtwy/main.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/cmd/gtwy/main.go b/cmd/gtwy/main.go index 84c9f18..1e9d3a3 100644 --- a/cmd/gtwy/main.go +++ b/cmd/gtwy/main.go @@ -10,16 +10,22 @@ import ( "gitlab.com/mokhax/spike/pkg/srv" ) -func main() { - mux := http.NewServeMux() - mux.Handle("/", prxy.New(map[string]string{ - "idp.example.com": "localhost:8282", - "ui.example.com": "localhost:8283", - "api.example.com": "localhost:8284", - })) +func WithRoutes() cfg.Option { + return func(c *cfg.Config) { + mux := http.NewServeMux() + mux.Handle("/", prxy.New(map[string]string{ + "idp.example.com": "localhost:8282", + "ui.example.com": "localhost:8283", + "api.example.com": "localhost:8284", + })) + + cfg.WithMux(mux)(c) + } +} +func main() { log.Fatal(srv.Run(cfg.New( env.Fetch("BIND_ADDR", ":8080"), - cfg.WithMux(mux), + WithRoutes(), ))) } |
