MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / buildRequestURL

Function buildRequestURL

token/transfer.go:93–115  ·  view source on GitHub ↗

BuildRequestURL creates a request suitable for a resource transfer. it will return a constructed url based off the base url and query key/value provided. cli will build a url for cli transfer request.

(baseURL *url.URL, appAUD string, key, value string, cli, useHostOnly bool, autoClose bool)

Source from the content-addressed store, hash-verified

91// it will return a constructed url based off the base url and query key/value provided.
92// cli will build a url for cli transfer request.
93func buildRequestURL(baseURL *url.URL, appAUD string, key, value string, cli, useHostOnly bool, autoClose bool) (string, error) {
94 q := baseURL.Query()
95 q.Set(key, value)
96 q.Set("aud", appAUD)
97 baseURL.RawQuery = q.Encode()
98 if useHostOnly {
99 baseURL.Path = ""
100 }
101 // TODO: pass arg for tunnel login
102 if !cli {
103 return baseURL.String(), nil
104 }
105 q.Set("redirect_url", baseURL.String()) // we add the token as a query param on both the redirect_url and the main url
106 q.Set("send_org_token", "true") // indicates that the cli endpoint should return both the org and app token
107 q.Set("edge_token_transfer", "true") // use new LoginHelper service built on workers
108 if autoClose {
109 q.Set("close_interstitial", "true") // Automatically close the success window.
110 }
111
112 baseURL.RawQuery = q.Encode() // and this actual baseURL.
113 baseURL.Path = "cdn-cgi/access/cli"
114 return baseURL.String(), nil
115}
116
117// transferRequest downloads the requested resource from the request URL
118func transferRequest(requestURL string, log *zerolog.Logger) ([]byte, string, error) {

Callers 1

RunTransferFunction · 0.85

Calls 3

StringMethod · 0.65
SetMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected