From cb5933ccf0320d109384fc3bdcb83582600a32b9 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Sat, 24 Dec 2022 17:10:47 +0100 Subject: [PATCH] DEBUG change --- consul/discovery.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/consul/discovery.go b/consul/discovery.go index 0880369..72a9daa 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -10,24 +10,26 @@ import ( ) type Service struct { - Name string - Address string - appID string - domain string - port int - ttl time.Duration - agent *consul.Agent - kv *consul.KV + Name string + Address string + appID string + domain string + pathPrefix string + port int + ttl time.Duration + agent *consul.Agent + kv *consul.KV } var ErrServiceUnavailable = fmt.Errorf("Service is unavailable") -func NewService(servAddr, id, name, hostname, domain string, appPort int) (*Service, error) { +func NewService(servAddr, id, name, hostname, domain, pathPrefix string, appPort int) (*Service, error) { s := new(Service) s.Name = name s.Address = hostname s.appID = id s.domain = domain + s.pathPrefix = pathPrefix s.port = appPort s.ttl = time.Second * 15 @@ -140,7 +142,7 @@ func (s *Service) getTags() []string { tags := []string{ "traefik.enable=true", // "traefik.http.routers." + s.Name + ".rule=Header(`X-API-SERVICE`, `" + s.Name + "`)", - "traefik.http.routers." + s.Name + ".rule=PathPrefix(`/catalog`)", + "traefik.http.routers." + s.Name + ".rule=PathPrefix(`{$s.pathPrefix}`)", "traefik.http.routers." + s.Name + ".entryPoints=https", "traefik.http.routers." + s.Name + ".tls=true", "traefik.http.routers." + s.Name + ".service=" + s.Name, @@ -149,7 +151,7 @@ func (s *Service) getTags() []string { "traefik.http.services." + s.Name + ".loadbalancer.server.port=" + strconv.Itoa(s.port), "traefik.http.services." + s.Name + ".loadbalancer.passhostheader=false", "traefik.http.middlewares.requestid.plugin.requestid.headerName=X-Request-ID", - "traefik.http.middlewares.stripPrefix.stripprefix.prefixes=/catalog", + "traefik.http.middlewares.stripPrefix.stripprefix.prefixes=`{$s.pathPrefix}`", "traefik.http.middlewares.compress.compress=true", // "traefik.http.middlewares.cors.headers.accesscontrolallowmethods=*", // "traefik.http.middlewares.cors.headers.accesscontrolalloworiginlist=*",