Files
trikotwaschliste/routes/routes.go
2020-10-12 00:16:23 +02:00

29 lines
797 B
Go

package routes
import (
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v4/pgxpool"
"trikotwaschliste/handler"
"trikotwaschliste/logbuffer"
"trikotwaschliste/models"
)
func RoutesInit(router *gin.Engine, pool *pgxpool.Pool, config *models.Config, logbuf *logbuffer.Queue) {
router.GET("/", handler.MainPage(pool))
router.GET("/credits", handler.Credits())
router.POST("/uploadname", handler.UploadName(pool))
router.GET("/persons", handler.ShowPersonsList(pool))
// Basic auth accounts
authorized := router.Group("/admin", gin.BasicAuth(gin.Accounts{
config.ADMIN_NAME: config.ADMIN_PASSWORD,
}))
// Basic auth routes
authorized.GET("/", handler.AdminMainPage(pool))
authorized.POST("/changename", handler.ChangeName(pool))
authorized.GET("/logs", handler.Logs(logbuf))
}