Skip to content

Commit

Permalink
feat: pathing is working
Browse files Browse the repository at this point in the history
  • Loading branch information
Kote committed Nov 15, 2023
1 parent c972294 commit 613a601
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions boltrouter/bolt_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,14 @@ func (br *BoltRouter) newBoltRequestForGcp(ctx context.Context, logger *zap.Logg
}

req.RequestURI = ""
logger.Debug("req.URL.Path", zap.String("path", req.URL.Path))
logger.Debug("req.URL.RawPath", zap.String("path", req.URL.RawPath))
logger.Debug("req.URL.EscapedPath", zap.String("path", req.URL.EscapedPath()))

escapedPath, escapePathErr := escapeGCSPath(req.URL.Path, logger)
logger.Debug("escapedPath", zap.String("path", escapedPath))
if escapePathErr != nil {
logger.Debug("Error escaping path, using original path")
BoltURL.Path = req.URL.Path
} else {
BoltURL.Path = escapedPath
}

logger.Debug("BoltURL.Path", zap.String("path", BoltURL.Path))

if !strings.HasPrefix(BoltURL.Path, "/") {
BoltURL.Path = "/" + BoltURL.Path
}
Expand All @@ -185,21 +178,16 @@ func (br *BoltRouter) newBoltRequestForGcp(ctx context.Context, logger *zap.Logg

gcpRequest := req.Clone(ctx)
gcsUrl, _ := url.Parse("https://storage.googleapis.com")
if escapePathErr != nil {
logger.Debug("gcp: Error escaping path, using original path")
gcsUrl.Path = req.URL.Path
} else {
gcsUrl.Path = escapedPath
}

logger.Debug("gcsUrl.Path", zap.String("path", gcsUrl.Path))
gcsUrl.Path = req.URL.Path
gcsUrl.RawPath = req.URL.RawPath

if !strings.HasPrefix(gcsUrl.Path, "/") {
gcsUrl.Path = "/" + gcsUrl.Path
}

gcsUrl.RawQuery = req.URL.RawQuery
gcpRequest.URL = gcsUrl
gcpRequest.Header.Set("Host", "storage.googleapis.com")
gcpRequest.Host = "storage.googleapis.com"

CopyReqBody(req, gcpRequest)
Expand Down

0 comments on commit 613a601

Please sign in to comment.