(resourcePath string)
| 54 | } |
| 55 | |
| 56 | func loadResourceFromURLOrEnv(resourcePath string) ([]byte, error) { |
| 57 | parts := strings.SplitAfterN(resourcePath, "://", 2) |
| 58 | // If the path does not contain a scheme, it is considered a file path |
| 59 | if len(parts) != 2 { |
| 60 | return nil, &UnrecognizedSchemeError{Scheme: parts[0]} |
| 61 | } |
| 62 | |
| 63 | switch parts[0] { |
| 64 | case "http://", "https://": |
| 65 | return loadFromURL(resourcePath) |
| 66 | case "env://": |
| 67 | return loadFromEnv(parts[1]) |
| 68 | default: |
| 69 | return nil, &UnrecognizedSchemeError{Scheme: parts[0]} |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // loadFromURL loads the content of a URL and returns it as a byte slice. |
| 74 | func loadFromURL(url string) ([]byte, error) { |
no test coverage detected