Endpoint retrieves endpoint without leading "/" from either `URL.Path` or `URL.Opaque`. The latter is used when the former is empty.
()
| 277 | // Endpoint retrieves endpoint without leading "/" from either `URL.Path` |
| 278 | // or `URL.Opaque`. The latter is used when the former is empty. |
| 279 | func (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. |
| 296 | func (t Target) String() string { |
no outgoing calls