Add mini fix MIME bug on Windows

This commit is contained in:
Ash Keel 2022-06-19 01:57:17 +02:00
parent a6b8ffa877
commit 42b76003d8
No known key found for this signature in database
GPG Key ID: BAD8D93E7314ED3E
2 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `game` command not working when the specified channel contained the @ symbol at the beginning.
- Fixed strimertul crashing at start if the database folder didn't exist and a database driver was not manually specified
- Fixed strimertul crashing after a minute of being open if Twitch was not configured.
- Hotfix for MIME bug in Windows (`.js` files erraneously being interpreted as `text/plain`). This is fixed will be Go 1.19, but is still provided for Go 1.18 builds.
## [2.1.1] - 2022-03-24

View File

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io/fs"
"mime"
"net/http"
"net/http/pprof"
@ -37,12 +38,18 @@ func NewServer(manager *modules.Manager) (*Server, error) {
logger := manager.Logger(modules.ModuleHTTP)
// Fix mime type bug in Windows (fixed in Go 1.19)
err := mime.AddExtensionType(".js", "text/javascript; charset=utf-8")
if err != nil {
logger.Warn("Failed to set fix for mime-type bug", zap.Error(err))
}
server := &Server{
logger: logger,
db: db,
server: &http.Server{},
}
err := db.GetJSON(ServerConfigKey, &server.Config)
err = db.GetJSON(ServerConfigKey, &server.Config)
if err != nil {
// Initialize with default config
server.Config = ServerConfig{