Skip to content

Commit

Permalink
Add mime.type for yaml
Browse files Browse the repository at this point in the history
According to
https://www.ietf.org/archive/id/draft-ietf-httpapi-yaml-mediatypes-00.html,
we should be using `application/yaml`, but since GCS uses
application/x-yaml, and we emulate GCS, we stick to what GCS' behavior.

Closes #990.
  • Loading branch information
fsouza committed Nov 16, 2022
1 parent b25dbd0 commit a0bc438
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
var emptyBuckets []string
opts := cfg.ToFakeGcsOptions()
if cfg.Seed != "" {
addMimeTypes()
opts.InitialObjects, emptyBuckets = generateObjectsFromFiles(logger, cfg.Seed)
}

Expand All @@ -50,6 +51,16 @@ func main() {
<-ch
}

func addMimeTypes() {
mapping := map[string]string{
".yaml": "application/x-yaml",
".yml": "application/x-yaml",
}
for ext, typ := range mapping {
mime.AddExtensionType(ext, typ)
}
}

func generateObjectsFromFiles(logger *logrus.Logger, folder string) ([]fakestorage.Object, []string) {
var objects []fakestorage.Object
var emptyBuckets []string
Expand Down

0 comments on commit a0bc438

Please sign in to comment.