frostfs-http-gw/utils/util.go
Denis Kirillov 1e05d8a935 [#200] Reload resolvers on SIGHUP
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-09-16 17:08:20 +03:00

19 lines
537 B
Go

package utils
import (
"context"
"github.com/nspcc-dev/neofs-http-gw/resolver"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
)
// GetContainerID decode container id, if it's not a valid container id
// then trey to resolve name using provided resolver.
func GetContainerID(ctx context.Context, containerID string, resolver *resolver.ContainerResolver) (*cid.ID, error) {
cnrID := new(cid.ID)
err := cnrID.DecodeString(containerID)
if err != nil {
cnrID, err = resolver.Resolve(ctx, containerID)
}
return cnrID, err
}