Initial commit 3.
This commit is contained in:
@@ -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"})
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"`
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user