Skip to content

Commit c520694

Browse files
authored
Bugfix (#158)
1 parent 9ee69dd commit c520694

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

pkg/cmd/global.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ func (g *global) URL() *url.URL {
152152
return g.url
153153
}
154154

155+
func (g *global) SetURL(url *url.URL) {
156+
g.url = url
157+
}
158+
155159
func (g *global) IsTerm() int {
156160
return TerminalWidth()
157161
}

pkg/cmd/server.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"crypto/tls"
55
"fmt"
6+
"net/url"
67
"os"
78

89
// Packages
@@ -99,9 +100,14 @@ func (s *RunServer) Run(ctx server.Cmd) error {
99100
if err := srv.Listen(); err != nil {
100101
return err
101102
}
102-
if url := srv.URL(); url != nil {
103-
url.Path = types.NormalisePath(ctx.HTTPPrefix())
104-
ctx.(*global).url = url
103+
if u := srv.URL(); u != nil {
104+
u.Path = types.NormalisePath(ctx.HTTPPrefix())
105+
type urlSetter interface {
106+
SetURL(*url.URL)
107+
}
108+
if ctx, ok := ctx.(urlSetter); ok {
109+
ctx.SetURL(u)
110+
}
105111
}
106112

107113
// Build middleware chain: OTel HTTP middleware which emits traces, logs and metrics

0 commit comments

Comments
 (0)