mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-09 13:17:46 +02:00
feat:#36 added real ip for proxy, extended error logging
This commit is contained in:
@@ -18,18 +18,25 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/gofiber/fiber/v3/log"
|
||||
"github.com/gofiber/fiber/v3/middleware/logger"
|
||||
"htwkalender/ical/model"
|
||||
"htwkalender/ical/service"
|
||||
"htwkalender/ical/service/connector/grpc"
|
||||
"log/slog"
|
||||
"os"
|
||||
)
|
||||
|
||||
// main function for the ical service
|
||||
// uses rest api to get the data from the data-manager
|
||||
// exposes rest api endpoints with fiber to serve the data for clients
|
||||
func main() {
|
||||
const host = "htwkalender-data-manager"
|
||||
|
||||
// get host from env if this is not set use default value 127.0.0.1
|
||||
|
||||
host := os.Getenv("DATA_MANAGER_URL")
|
||||
if host == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
|
||||
grpcClient := grpc.ConnectGRPCServer(host)
|
||||
defer grpc.CloseGRPCServer(grpcClient)
|
||||
@@ -38,11 +45,14 @@ func main() {
|
||||
webdavRequestMethods := []string{"PROPFIND", "MKCOL", "COPY", "MOVE"}
|
||||
|
||||
fiberApp := fiber.New(fiber.Config{
|
||||
CaseSensitive: true,
|
||||
StrictRouting: true,
|
||||
ServerHeader: "Fiber",
|
||||
AppName: "App Name",
|
||||
RequestMethods: append(fiber.DefaultMethods[:], webdavRequestMethods...),
|
||||
CaseSensitive: true,
|
||||
StrictRouting: true,
|
||||
ServerHeader: "HTWKalender iCal Service",
|
||||
AppName: "HTWKalender iCal Service",
|
||||
RequestMethods: append(fiber.DefaultMethods[:], webdavRequestMethods...),
|
||||
EnableTrustedProxyCheck: true,
|
||||
TrustedProxies: []string{"172.16.0.0/12", "172.18.0.5", "172.18.0.1"},
|
||||
ProxyHeader: "X-Forwarded-For",
|
||||
})
|
||||
|
||||
var app = model.AppType{
|
||||
@@ -57,5 +67,5 @@ func main() {
|
||||
// Add routes to the app instance for the data-manager ical service
|
||||
service.AddFeedRoutes(app)
|
||||
|
||||
log.Fatal(fiberApp.Listen(":8091"))
|
||||
slog.Info("Starting ical service", fiberApp.Listen(":8091"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user