Scheme returns the URI scheme. Possible values are http, https, grpc, and grpcs.
()
| 270 | // Scheme returns the URI scheme. Possible values are http, https, grpc, and |
| 271 | // grpcs. |
| 272 | func (u URIExpr) Scheme() string { |
| 273 | ustr := string(u) |
| 274 | // Did not use url package to find scheme because the url may |
| 275 | // contain params (i.e. http://{version}.example.com) which needs |
| 276 | // substition for url.Parse to succeed. Also URIs in host must have |
| 277 | // a scheme otherwise validations would have failed. |
| 278 | switch { |
| 279 | case strings.HasPrefix(ustr, "https"): |
| 280 | return "https" |
| 281 | case strings.HasPrefix(ustr, "grpcs"): |
| 282 | return "grpcs" |
| 283 | case strings.HasPrefix(ustr, "grpc"): |
| 284 | return "grpc" |
| 285 | default: |
| 286 | // No need to worry about other values because the URIExpr would have failed |
| 287 | // validation. |
| 288 | return "http" |
| 289 | } |
| 290 | } |
no outgoing calls
no test coverage detected