(currentURL string, port string)
| 147 | } |
| 148 | |
| 149 | func ReplacePort(currentURL string, port string) (string, error) { |
| 150 | if port == "" { |
| 151 | return currentURL, fmt.Errorf("failed to replace port in case of docker env") |
| 152 | } |
| 153 | |
| 154 | parsedURL, err := url.Parse(currentURL) |
| 155 | |
| 156 | if err != nil { |
| 157 | return currentURL, err |
| 158 | } |
| 159 | |
| 160 | if parsedURL.Port() == "" { |
| 161 | parsedURL.Host = parsedURL.Host + ":" + port |
| 162 | } else { |
| 163 | parsedURL.Host = strings.Replace(parsedURL.Host, parsedURL.Port(), port, 1) |
| 164 | } |
| 165 | |
| 166 | return parsedURL.String(), nil |
| 167 | } |
| 168 | |
| 169 | // GetReqMeta returns the metadata of the request |
| 170 | func GetReqMeta(req *http.Request) map[string]string { |
no test coverage detected