Skip to content

Commit

Permalink
chore: rename ListObjetV1Handler to ListObjectHandler, rename BTFS-Ha…
Browse files Browse the repository at this point in the history
…sh to CID
  • Loading branch information
imstevez committed Aug 30, 2023
1 parent bbfcb97 commit bbed9cd
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
6 changes: 1 addition & 5 deletions s3/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const (
XRequestWith = "X-Requested-With"
Range = "Range"
UserAgent = "User-Agent"
CID = "CID"
)

// Standard HTTP cors headers
Expand All @@ -157,11 +158,6 @@ const (
AccessControlAllowCredentials = "Access-Control-Allow-Credentials"
)

// Standard BTFS HTTP response constants
const (
BTFSHash = "BTFS-Hash"
)

// object const
const (
MaxObjectSize = 5 * humanize.TiByte
Expand Down
2 changes: 1 addition & 1 deletion s3/handlers/handlers_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (h *Handlers) GetObjectACLHandler(w http.ResponseWriter, r *http.Request) {
responses.WriteGetBucketAclResponse(w, r, ack, acl)
}

func (h *Handlers) ListObjectsV1Handler(w http.ResponseWriter, r *http.Request) {
func (h *Handlers) ListObjectsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
ack := cctx.GetAccessKey(r)
var err error
Expand Down
2 changes: 1 addition & 1 deletion s3/handlers/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var defaultCorsMethods = []string{
}

var defaultCorsHeaders = []string{
consts.BTFSHash,
consts.CID,
consts.Date,
consts.ETag,
consts.ServerInfo,
Expand Down
2 changes: 1 addition & 1 deletion s3/handlers/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Handlerser interface {
DeleteObjectHandler(w http.ResponseWriter, r *http.Request)
GetObjectHandler(w http.ResponseWriter, r *http.Request)
GetObjectACLHandler(w http.ResponseWriter, r *http.Request)
ListObjectsV1Handler(w http.ResponseWriter, r *http.Request)
ListObjectsHandler(w http.ResponseWriter, r *http.Request)
ListObjectsV2Handler(w http.ResponseWriter, r *http.Request)

// multipart
Expand Down
5 changes: 3 additions & 2 deletions s3/responses/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ type Object struct {
Key string
LastModified string // time string of format "2006-01-02T15:04:05.000Z"
ETag string
BTFSHash string // BTFS Cid
CID string // CID
Size int64

// Owner of the object.
Expand Down Expand Up @@ -261,6 +261,7 @@ func GenerateListObjectsV2Response(bucket, prefix, token, nextToken, startAfter,
}
content.Size = object.Size
content.Owner = owner
content.CID = object.Cid
contents = append(contents, content)
}
data.Name = bucket
Expand Down Expand Up @@ -307,7 +308,7 @@ func GenerateListObjectsV1Response(bucket, prefix, marker, delimiter, encodingTy
if object.ETag != "" {
content.ETag = "\"" + object.ETag + "\""
}
content.BTFSHash = object.Cid
content.CID = object.Cid
content.Size = object.Size
content.StorageClass = ""
content.Owner = owner
Expand Down
2 changes: 1 addition & 1 deletion s3/responses/writers_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ func setPutObjHeaders(w http.ResponseWriter, etag, cid string, delete bool) {
w.Header()[consts.ETag] = []string{`"` + etag + `"`}
}
if cid != "" {
w.Header()[consts.BTFSHash] = []string{cid}
w.Header()[consts.CID] = []string{cid}
}
}
4 changes: 2 additions & 2 deletions s3/routers/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func (routers *Routers) Register() http.Handler {
//object...
// ListObjectsV2
bucket.Methods(http.MethodGet).HandlerFunc(hs.ListObjectsV2Handler).Queries("list-type", "2")
// ListObjectsV1
bucket.Methods(http.MethodGet).HandlerFunc(hs.ListObjectsV1Handler)
// ListObjects
bucket.Methods(http.MethodGet).HandlerFunc(hs.ListObjectsHandler)
// HeadObject
bucket.Methods(http.MethodHead).Path("/{object:.+}").HandlerFunc(hs.HeadObjectHandler)
// PutObject
Expand Down

0 comments on commit bbed9cd

Please sign in to comment.