MCPcopy
hub / github.com/grpc/grpc-go / Endpoint

Method Endpoint

resolver/resolver.go:279–293  ·  view source on GitHub ↗

Endpoint retrieves endpoint without leading "/" from either `URL.Path` or `URL.Opaque`. The latter is used when the former is empty.

()

Source from the content-addressed store, hash-verified

277// Endpoint retrieves endpoint without leading "/" from either `URL.Path`
278// or `URL.Opaque`. The latter is used when the former is empty.
279func (t Target) Endpoint() string {
280 endpoint := t.URL.Path
281 if endpoint == "" {
282 endpoint = t.URL.Opaque
283 }
284 // For targets of the form "[scheme]://[authority]/endpoint, the endpoint
285 // value returned from url.Parse() contains a leading "/". Although this is
286 // in accordance with RFC 3986, we do not want to break existing resolver
287 // implementations which expect the endpoint without the leading "/". So, we
288 // end up stripping the leading "/" here. But this will result in an
289 // incorrect parsing for something like "unix:///path/to/socket". Since we
290 // own the "unix" resolver, we can workaround in the unix resolver by using
291 // the `URL` field.
292 return strings.TrimPrefix(endpoint, "/")
293}
294
295// String returns the canonical string representation of Target.
296func (t Target) String() string {

Callers 15

StringMethod · 0.95
initAuthorityMethod · 0.80
sendNewPickerLockedMethod · 0.80
BuildMethod · 0.80
NewFunction · 0.80
BuildMethod · 0.80
BuildMethod · 0.80
startMethod · 0.80
verifyDNSResolutionFunction · 0.80

Calls

no outgoing calls