feat: initialize cache and use it in context
This commit is contained in:
@@ -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"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user