You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the excellent library!
Two small things worth signalling which make it not a perfect drop-in:
In case the mime type cannot be determined from the extension by the mime.TypeByExtension method, ServeContent will try to infer from the actual file content: https://golang.org/src/net/http/fs.go?s=4932:5036#L198 so it will return a type like "application/x-gzip", whereas http.FileServer would have return "text/plain" for a YAML file, for example. This can lead to bugs, for example when trying to use the Swagger UI.
=> workaround: register such non-standard types (there's actually no official mime type for YAML):
mime.AddExtensionType(".yaml", "application/x-yaml")
http.FileServer can find a file requested as "static/test.html" (for example when using http.StripPrefix) whereas gzipped.FileServer requires the leading "/"
Thanks!
Ben
The text was updated successfully, but these errors were encountered:
Thanks for the excellent library!
Two small things worth signalling which make it not a perfect drop-in:
=> workaround: register such non-standard types (there's actually no official mime type for YAML):
mime.AddExtensionType(".yaml", "application/x-yaml")
Thanks!
Ben
The text was updated successfully, but these errors were encountered: