Skip to content

Commit

Permalink
do not append port number if http or https
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashNephy committed Oct 11, 2024
1 parent 49fdc56 commit c57fec7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,27 @@ func main() {
}
}

func buildURL(scheme string, host string, port uint16) *url.URL {
switch {
case scheme == "http" && port == 80, scheme == "https" && port == 443:
return &url.URL{
Scheme: scheme,
Host: host,
}
default:
return &url.URL{
Scheme: scheme,
Host: fmt.Sprintf("%s:%d", host, port),
}
}
}

func execute(ctx context.Context) error {
file := external.NewBonDriverChannelFile()

client := &http.Client{}
mirakurun := external.NewMirakurunClient(client, &url.URL{Scheme: opts.MirakurunScheme, Host: fmt.Sprintf("%s:%d", opts.MirakurunHost, opts.MirakurunPort)}, opts.RequestHeaders)
epgstation := external.NewEPGStationClient(client, &url.URL{Scheme: opts.EPGStationScheme, Host: fmt.Sprintf("%s:%d", opts.EPGStationHost, opts.EPGStationPort)}, opts.RequestHeaders)
mirakurun := external.NewMirakurunClient(client, buildURL(opts.MirakurunScheme, opts.MirakurunHost, opts.MirakurunPort), opts.RequestHeaders)
epgstation := external.NewEPGStationClient(client, buildURL(opts.EPGStationScheme, opts.EPGStationHost, opts.EPGStationPort), opts.RequestHeaders)

services, err := mirakurun.GetServices(ctx)
if err != nil {
Expand Down

0 comments on commit c57fec7

Please sign in to comment.