mirror of
https://github.com/pushbits/server.git
synced 2025-06-01 10:12:02 +02:00
Initialize repository
This commit is contained in:
commit
1d758fcfd0
28 changed files with 1107 additions and 0 deletions
45
router/router.go
Normal file
45
router/router.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/eikendev/pushbits/api"
|
||||
"github.com/eikendev/pushbits/authentication"
|
||||
"github.com/eikendev/pushbits/database"
|
||||
"github.com/eikendev/pushbits/dispatcher"
|
||||
|
||||
"github.com/gin-contrib/location"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Create a Gin engine and setup all routes.
|
||||
func Create(db *database.Database, dp *dispatcher.Dispatcher) *gin.Engine {
|
||||
log.Println("Setting up HTTP routes.")
|
||||
|
||||
auth := authentication.Authenticator{DB: db}
|
||||
|
||||
applicationHandler := api.ApplicationHandler{DB: db, Dispatcher: dp}
|
||||
notificationHandler := api.NotificationHandler{DB: db, Dispatcher: dp}
|
||||
userHandler := api.UserHandler{DB: db}
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(location.Default())
|
||||
|
||||
applicationGroup := r.Group("/application")
|
||||
applicationGroup.Use(auth.RequireUser())
|
||||
{
|
||||
applicationGroup.POST("", applicationHandler.CreateApplication)
|
||||
//applicationGroup.DELETE("/:id", applicationHandler.DeleteApplication)
|
||||
}
|
||||
|
||||
r.POST("/message", auth.RequireApplicationToken(), notificationHandler.CreateNotification)
|
||||
|
||||
userGroup := r.Group("/user")
|
||||
userGroup.Use(auth.RequireAdmin())
|
||||
{
|
||||
userGroup.POST("", userHandler.CreateUser)
|
||||
//userGroup.DELETE("/:id", userHandler.DeleteUser)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue