summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gtwy/main.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/cmd/gtwy/main.go b/cmd/gtwy/main.go
index 3d4a2472..8d1baa6f 100644
--- a/cmd/gtwy/main.go
+++ b/cmd/gtwy/main.go
@@ -6,11 +6,11 @@ import (
"net/http"
"net/http/httputil"
"strings"
- "time"
"github.com/casbin/casbin/v2"
"github.com/xlgmokha/x/pkg/env"
"github.com/xlgmokha/x/pkg/x"
+ "gitlab.com/mokhax/spike/pkg/srv"
)
func NewRouter(routes map[string]string) http.Handler {
@@ -48,21 +48,14 @@ func NewRouter(routes map[string]string) http.Handler {
func main() {
mux := http.NewServeMux()
- routes := map[string]string{
+ mux.Handle("/", NewRouter(map[string]string{
"idp.example.com": "localhost:8282",
"ui.example.com": "localhost:8283",
"api.example.com": "localhost:8284",
- }
- mux.Handle("/", NewRouter(routes))
+ }))
- bindAddress := env.Fetch("BIND_ADDR", ":8080")
- log.Fatal((&http.Server{
- Addr: bindAddress,
- Handler: mux,
- ReadHeaderTimeout: 10 * time.Second,
- ReadTimeout: 30 * time.Second,
- WriteTimeout: 2 * time.Minute,
- IdleTimeout: 5 * time.Minute,
- ErrorLog: log.Default(),
- }).ListenAndServe())
+ log.Fatal(srv.Run(srv.NewConfig(
+ env.Fetch("BIND_ADDR", ":8080"),
+ srv.WithMux(mux),
+ )))
}