mirror of
https://github.com/pushbits/server.git
synced 2025-06-03 19:22:05 +02:00
Merge branch 'main' into trustedproxies
This commit is contained in:
commit
69d92f52c8
12 changed files with 176 additions and 28 deletions
|
@ -5,15 +5,17 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/pushbits/server/internal/api"
|
||||
"github.com/pushbits/server/internal/api/alertmanager"
|
||||
"github.com/pushbits/server/internal/authentication"
|
||||
"github.com/pushbits/server/internal/authentication/credentials"
|
||||
"github.com/pushbits/server/internal/configuration"
|
||||
"github.com/pushbits/server/internal/database"
|
||||
"github.com/pushbits/server/internal/dispatcher"
|
||||
"github.com/pushbits/server/internal/log"
|
||||
)
|
||||
|
||||
// Create a Gin engine and setup all routes.
|
||||
func Create(debug bool, trustedProxies []string, cm *credentials.Manager, db *database.Database, dp *dispatcher.Dispatcher) (*gin.Engine, error) {
|
||||
func Create(debug bool, trustedProxies []string, cm *credentials.Manager, db *database.Database, dp *dispatcher.Dispatcher, alertmanagerConfig *configuration.Alertmanager) (*gin.Engine, error) {
|
||||
log.L.Println("Setting up HTTP routes.")
|
||||
|
||||
if !debug {
|
||||
|
@ -26,6 +28,10 @@ func Create(debug bool, trustedProxies []string, cm *credentials.Manager, db *da
|
|||
healthHandler := api.HealthHandler{DB: db}
|
||||
notificationHandler := api.NotificationHandler{DB: db, DP: dp}
|
||||
userHandler := api.UserHandler{AH: &applicationHandler, CM: cm, DB: db, DP: dp}
|
||||
alertmanagerHandler := alertmanager.AlertmanagerHandler{DP: dp, Settings: alertmanager.AlertmanagerHandlerSettings{
|
||||
TitleAnnotation: alertmanagerConfig.AnnotationTitle,
|
||||
MessageAnnotation: alertmanagerConfig.AnnotationMessage,
|
||||
}}
|
||||
|
||||
r := gin.New()
|
||||
r.Use(log.GinLogger(log.L), gin.Recovery())
|
||||
|
@ -69,5 +75,7 @@ func Create(debug bool, trustedProxies []string, cm *credentials.Manager, db *da
|
|||
userGroup.PUT("/:id", api.RequireIDInURI(), userHandler.UpdateUser)
|
||||
}
|
||||
|
||||
r.POST("/alert", auth.RequireApplicationToken(), alertmanagerHandler.CreateAlert)
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue