proxyips hinzugefügt

This commit is contained in:
HuskyTeufel
2022-01-18 15:55:32 +01:00
parent 9a1dca8c97
commit e1eee90be6
3 changed files with 9 additions and 5 deletions

1
.env
View File

@@ -2,3 +2,4 @@ DB_HOST=localhost
DB_USER=besucher DB_USER=besucher
DB_PASS=besucher DB_PASS=besucher
DB_DATA=besucher DB_DATA=besucher
PROXYIP=172.19.0.2

2
app.go
View File

@@ -13,12 +13,14 @@ import (
type App struct { type App struct {
r *gin.Engine r *gin.Engine
proxyips []string
db *gorm.DB db *gorm.DB
} }
func (a *App) start() { func (a *App) start() {
a.db.AutoMigrate(&planner.Besucher{}) a.db.AutoMigrate(&planner.Besucher{})
a.r.Use(CORSMiddleware()) a.r.Use(CORSMiddleware())
a.r.SetTrustedProxies(a.proxyips)
a.r.NoRoute((func(c *gin.Context) { a.r.NoRoute((func(c *gin.Context) {
dir, file := path.Split(c.Request.RequestURI) dir, file := path.Split(c.Request.RequestURI)
ext := filepath.Ext(file) ext := filepath.Ext(file)

View File

@@ -30,6 +30,7 @@ func main() {
app := App{ app := App{
db: db, db: db,
r: gin.Default(), r: gin.Default(),
proxyips: []string{"172.19.0.2"},
} }
app.start() app.start()
//r := gin.Default() //r := gin.Default()