2020-07-24 16:10:41 +00:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
2020-08-06 10:49:25 +00:00
|
|
|
"errors"
|
2020-07-24 16:10:41 +00:00
|
|
|
|
2020-08-06 12:02:13 +00:00
|
|
|
"github.com/nspcc-dev/neofs-s3-gate/api"
|
|
|
|
"github.com/nspcc-dev/neofs-s3-gate/api/layer"
|
2020-07-24 16:10:41 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
handler struct {
|
|
|
|
log *zap.Logger
|
2020-08-06 10:49:25 +00:00
|
|
|
obj layer.Client
|
2020-07-24 16:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Params struct {
|
|
|
|
Log *zap.Logger
|
2020-08-06 10:49:25 +00:00
|
|
|
Obj layer.Client
|
2020-07-24 16:10:41 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2020-08-19 11:52:44 +00:00
|
|
|
const notSupported = "Not supported by NeoFS S3 Gate: "
|
|
|
|
|
2020-07-24 16:10:41 +00:00
|
|
|
var _ api.Handler = (*handler)(nil)
|
|
|
|
|
2020-08-06 10:49:25 +00:00
|
|
|
func New(log *zap.Logger, obj layer.Client) (api.Handler, error) {
|
2020-07-24 16:10:41 +00:00
|
|
|
switch {
|
2020-08-06 10:49:25 +00:00
|
|
|
case obj == nil:
|
|
|
|
return nil, errors.New("empty NeoFS Object Layer")
|
|
|
|
case log == nil:
|
2020-07-24 16:10:41 +00:00
|
|
|
return nil, errors.New("empty logger")
|
|
|
|
}
|
|
|
|
|
|
|
|
return &handler{
|
2020-08-06 10:49:25 +00:00
|
|
|
log: log,
|
|
|
|
obj: obj,
|
2020-07-24 16:10:41 +00:00
|
|
|
}, nil
|
|
|
|
}
|