/*
 * Project: Video Sharing Platform
 * Year: 2026
 * Developed by: Molla Samser (Founder of RSK World)
 * 
 * Custom middleware for authentication and logging.
 */

package main

import (
	"log"
	"time"

	"github.com/gin-gonic/gin"
)

func RSKLogger() gin.HandlerFunc {
	return func(c *gin.Context) {
		t := time.Now()

		c.Next()

		latency := time.Since(t)
		status := c.Writer.Status()

		log.Printf("[RSK 2026] %s %s | %v | %d | Developed by Molla Samser", 
			c.Request.Method, c.Request.URL.Path, latency, status)
	}
}

func AuthMiddleware() gin.HandlerFunc {
	return func(c *gin.Context) {
		token := c.GetHeader("Authorization")
		if token == "" {
			// In production, we would validate the token
			log.Println("[Auth] Anonymous access granted to RSK Platform")
		}
		c.Next()
	}
}
