Format takes a path and returns its URL. For example, given "/api/GetSelf", Format will return "https://subtrace.dev/api/GetSelf" as the URL. The SUBTRACE_ENDPOINT environment variable can be used to override the domain name used.
(path string)
| 23 | // The SUBTRACE_ENDPOINT environment variable can be used to override the |
| 24 | // domain name used. |
| 25 | func Format(path string) string { |
| 26 | if path == "" { |
| 27 | path = "/" |
| 28 | } |
| 29 | if !strings.HasPrefix(path, "/") { // TODO: is this too relaxed? |
| 30 | path = "/" + path |
| 31 | } |
| 32 | return getEndpoint() + path |
| 33 | } |