Skip to content

Commit

Permalink
chore: set user agent when doing lsp requests (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored Aug 15, 2024
1 parent cf124a1 commit 8837aee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/lsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/getAlby/hub/logger"
"github.com/getAlby/hub/lsp"
"github.com/getAlby/hub/utils"
"github.com/getAlby/hub/version"
decodepay "github.com/nbd-wtf/ln-decodepay"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -126,6 +127,7 @@ func (api *api) getLSPS1LSPInfo(url string) (*lspInfo, error) {
}).Error("Failed to create lsp info request")
return nil, err
}
setDefaultRequestHeaders(req)

res, err := client.Do(req)
if err != nil {
Expand Down Expand Up @@ -244,6 +246,7 @@ func (api *api) requestLSPS1Invoice(ctx context.Context, request *LSPOrderReques
return "", 0, err
}

setDefaultRequestHeaders(req)
req.Header.Set("Content-Type", "application/json")

res, err := client.Do(req)
Expand Down Expand Up @@ -307,3 +310,7 @@ func (api *api) requestLSPS1Invoice(ctx context.Context, request *LSPOrderReques

return invoice, fee, nil
}

func setDefaultRequestHeaders(req *http.Request) {
req.Header.Set("User-Agent", "AlbyHub/"+version.Tag)
}

0 comments on commit 8837aee

Please sign in to comment.