add: implement shortlink
This commit is contained in:
@@ -55,7 +55,7 @@ func SetupRouter(cfg *config.Config, logger *zap.Logger) http.Handler {
|
||||
// Initialize JWT auth service
|
||||
jwtSecret := cfg.Auth.JWTSecret
|
||||
if jwtSecret == "" {
|
||||
jwtSecret = "vQ6PQqUyh7pBNOytClgN+Nw1XBq7F8Qo6VP3VwIqvHY=" // Default from your example, should be set in config
|
||||
logger.Warn("JWT secret not provided in config")
|
||||
}
|
||||
|
||||
// Convert config values to time.Duration
|
||||
@@ -66,6 +66,15 @@ func SetupRouter(cfg *config.Config, logger *zap.Logger) http.Handler {
|
||||
jwtManager := auth.NewJWTManager(jwtSecret, accessExpiry, refreshExpiry)
|
||||
authService := service.NewAuthService(jwtManager)
|
||||
|
||||
// Initialize shortlink service with config values
|
||||
shortLinkService := service.NewShortLinkService(
|
||||
jwtManager,
|
||||
logger,
|
||||
cfg.Shortlink.BaseURL,
|
||||
cfg.Shortlink.DefaultExpiryHours,
|
||||
cfg.Shortlink.MaxAttempts,
|
||||
)
|
||||
|
||||
// Public routes that don't require authentication
|
||||
r.Group(func(r chi.Router) {
|
||||
// Health check
|
||||
@@ -77,6 +86,10 @@ func SetupRouter(cfg *config.Config, logger *zap.Logger) http.Handler {
|
||||
r.Post("/login", authHandler.Login)
|
||||
r.Post("/refresh", authHandler.RefreshToken)
|
||||
r.Post("/logout", authHandler.Logout)
|
||||
|
||||
// ShortLink authentication - no auth required
|
||||
shortLinkHandler := handlers.NewShortLinkHandler(logger, shortLinkService)
|
||||
r.Post("/shortlink", shortLinkHandler.ShortLinkAuth)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -85,6 +98,10 @@ func SetupRouter(cfg *config.Config, logger *zap.Logger) http.Handler {
|
||||
// Apply authentication middleware
|
||||
r.Use(apiMiddleware.Auth(authService, logger))
|
||||
|
||||
// Shortlink generation - only for admin and expertise_doctor roles
|
||||
shortLinkHandler := handlers.NewShortLinkHandler(logger, shortLinkService)
|
||||
r.Post("/generate-link", shortLinkHandler.GenerateShortLink)
|
||||
|
||||
// DICOM Web routes
|
||||
r.Route("/dicomWeb", func(r chi.Router) {
|
||||
// Add audit logging middleware to DICOM routes
|
||||
|
||||
Reference in New Issue
Block a user