mimetype added. Thanks page added

This commit is contained in:
HuskyTeufel
2022-02-09 14:38:28 +01:00
parent 1e86549b69
commit eb563671f2
9 changed files with 67 additions and 17 deletions

9
app.go
View File

@@ -1,6 +1,7 @@
package main
import (
"mime"
"path"
"path/filepath"
@@ -20,6 +21,7 @@ type App struct {
func (a *App) start() {
a.db.AutoMigrate(&planner.Besucher{})
a.r.Use(CORSMiddleware())
a.r.Use(HEADERMiddleWare())
a.r.SetTrustedProxies(a.proxyips)
a.r.NoRoute((func(c *gin.Context) {
dir, file := path.Split(c.Request.RequestURI)
@@ -46,6 +48,13 @@ func (a *App) start() {
}
}
func HEADERMiddleWare() gin.HandlerFunc {
return func(c *gin.Context) {
mime.AddExtensionType(".js", "application/javascript")
c.Next()
}
}
func CORSMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")