refactor headers into a dedicated package

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2022-01-14 14:14:35 +00:00
parent 6b935e47d0
commit 5b97a12acd
2 changed files with 11 additions and 19 deletions

View File

@@ -25,6 +25,7 @@ import (
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/graph/pkg/service/v0/errorcode"
"github.com/owncloud/ocis/graph/pkg/service/v0/net/headers"
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
sproto "github.com/owncloud/ocis/settings/pkg/proto/v0"
settingsSvc "github.com/owncloud/ocis/settings/pkg/service/v0"
@@ -33,12 +34,6 @@ import (
merrors "go-micro.dev/v4/errors"
)
const (
// "github.com/cs3org/reva/internal/http/services/datagateway" is internal so we redeclare it here
// TokenTransportHeader holds the header key for the reva transfer token
TokenTransportHeader = "X-Reva-Transfer"
)
// GetDrives implements the Service interface.
func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) {
g.logger.Info().Msg("Calling GetDrives")
@@ -464,18 +459,6 @@ type spaceYamlEntry struct {
rootMtime *types.Timestamp
}
/*
parent reference could be used to indicate the parent
"parentReference": {
"driveId": "c12644a14b0a7750",
"driveType": "personal",
"id": "C12644A14B0A7750!1383",
"name": "Screenshots",
"path": "/drive/root:/Bilder/Screenshots"
},
*/
func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageSpace) (*SpaceYaml, error) {
// if the root mtime
@@ -533,7 +516,7 @@ func (g Graph) getSpaceYaml(ctx context.Context, space *storageprovider.StorageS
return nil, err
}
// httpReq.Header.Set(ctxpkg.TokenHeader, auth)
httpReq.Header.Set(TokenTransportHeader, tk)
httpReq.Header.Set(headers.TokenTransportHeader, tk)
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
InsecureSkipVerify: true, //nolint:gosec

View File

@@ -0,0 +1,9 @@
package headers
const (
// "github.com/cs3org/reva/internal/http/services/datagateway" is internal so we redeclare it here
// TokenTransportHeader holds the header key for the reva transfer token
TokenTransportHeader = "X-Reva-Transfer"
// IfModifiedSince is used to mimic/pass on caching headers when using grpc
IfModifiedSince = "If-Modified-Since"
)