feat: initialize cache and use it in context

This commit is contained in:
Alex Wellnitz
2025-09-12 15:42:21 +02:00
parent cba8e97a30
commit 71db22ef46
4 changed files with 34 additions and 3 deletions

View File

@@ -4,17 +4,26 @@ import (
"net/http"
"git.dev-null.rocks/alexohneander/distributed-cache/api"
"git.dev-null.rocks/alexohneander/distributed-cache/pkg/cache"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func Start() {
e := echo.New()
e.Use(middleware.Logger())
// Initialize Cache
cache := cache.NewCache()
// Routes
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.GET("/api/v1/cache/:id", api.GetItem)
// api/v1/cache
e.GET("/api/v1/cache/:id", api.GetItem(cache))
e.POST("/api/v1/cache", api.PostItem(cache))
e.Logger.Fatal(e.Start(":8080"))
}