mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-05-27 13:53:14 +00:00
Test out API requests from frontend to backend
This commit is contained in:
parent
53cbe6e26c
commit
8416549858
5 changed files with 87 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/Fluffy-Bean/TastyBites/front"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
|
@ -16,11 +18,17 @@ func Serve(c Config) {
|
|||
|
||||
if c.Logging {
|
||||
r.Use(middleware.Logger())
|
||||
r.Use(middleware.CORS())
|
||||
}
|
||||
r.Use(middleware.Recover())
|
||||
|
||||
r.StaticFS("/", front.DistDir)
|
||||
|
||||
api := r.Group("/api")
|
||||
api.GET("/items", func(e echo.Context) error {
|
||||
return e.JSON(http.StatusOK, sampleData)
|
||||
})
|
||||
|
||||
r.HideBanner = true
|
||||
r.Logger.Fatal(r.Start(c.Host))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue