Initial commit 3.

This commit is contained in:
2025-05-07 10:21:52 +08:00
parent 90fe018438
commit f1919ab7bd
12 changed files with 224 additions and 16 deletions
+12
View File
@@ -0,0 +1,12 @@
package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
)
// HealthCheck responds with a simple health status
func HealthCheck(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "ok"})
}
+19
View File
@@ -0,0 +1,19 @@
package middleware
import (
"log"
"time"
"github.com/gin-gonic/gin"
)
// Logger is a simple request logger middleware
func Logger() gin.HandlerFunc {
return func(c *gin.Context) {
start := time.Now()
c.Next()
log.Printf("%s %s %d %s", c.Request.Method, c.Request.URL.Path, c.Writer.Status(), time.Since(start))
}
}
// TODO: Add more middleware (e.g., CORS, Auth) as needed
+9
View File
@@ -0,0 +1,9 @@
package models
// ExampleModel is a placeholder for future data models
// TODO: Define your data models here
type ExampleModel struct {
ID int `json:"id"`
Name string `json:"name"`
}
+14
View File
@@ -0,0 +1,14 @@
package routes
import (
"starter/backend/internal/handlers"
"starter/backend/internal/middleware"
"github.com/gin-gonic/gin"
)
// RegisterRoutes registers all API routes under the given group
func RegisterRoutes(rg *gin.RouterGroup) {
rg.Use(middleware.Logger())
rg.GET("/health", handlers.HealthCheck)
}