mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 04:48:26 +08:00
refactor: Reduce zb binary size (#1783)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"gopkg.in/resty.v1"
|
||||
)
|
||||
|
||||
func Location(baseURL string, resp *resty.Response) string {
|
||||
// For some API responses, the Location header is set and is supposed to
|
||||
// indicate an opaque value. However, it is not clear if this value is an
|
||||
// absolute URL (https://server:port/v2/...) or just a path (/v2/...)
|
||||
// zot implements the latter as per the spec, but some registries appear to
|
||||
// return the former - this needs to be clarified
|
||||
loc := resp.Header().Get("Location")
|
||||
|
||||
uloc, err := url.Parse(loc)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
path := uloc.Path
|
||||
|
||||
return baseURL + path
|
||||
}
|
||||
Reference in New Issue
Block a user