[#1] Add route to get object info

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-04-11 14:18:26 +03:00 committed by Alex Vanin
parent d9798cbce8
commit 066656ac48
14 changed files with 1032 additions and 70 deletions

View file

@ -41,10 +41,10 @@ type BearerToken struct {
type ContextKey string
const (
// BearerPrefix is the prefix for authorization token
// BearerPrefix is the prefix for authorization token.
BearerPrefix = "Bearer "
// ContextKeyRequestID is the ContextKey for RequestID
// ContextKeyRequestID is the ContextKey for RequestID.
ContextKeyRequestID ContextKey = "requestID"
)
@ -62,9 +62,13 @@ func (a *API) Configure(api *operations.NeofsRestGwAPI) http.Handler {
api.ServeError = errors.ServeError
api.AuthHandler = operations.AuthHandlerFunc(a.PostAuth)
api.PutObjectHandler = operations.PutObjectHandlerFunc(a.PutObjects)
api.GetObjectInfoHandler = operations.GetObjectInfoHandlerFunc(a.GetObjectInfo)
api.PutContainerHandler = operations.PutContainerHandlerFunc(a.PutContainers)
api.GetContainerHandler = operations.GetContainerHandlerFunc(a.GetContainer)
api.BearerAuthAuth = func(s string) (*models.Principal, error) {
if !strings.HasPrefix(s, BearerPrefix) {
return nil, fmt.Errorf("has not bearer token")