init Project ✌️✌️

This commit is contained in:
Kenta420-Poom 2023-09-14 14:52:04 +07:00
commit 8a6dc19bdd
42 changed files with 249179 additions and 0 deletions

28
server/routers/recipe.go Normal file
View file

@ -0,0 +1,28 @@
package routers
import (
"encoding/json"
"net/http"
"recipe-manager/data"
"github.com/go-chi/chi/v5"
)
type RecipeRouter struct {
data *data.Data
}
func NewRecipeRouter(data *data.Data) *RecipeRouter {
return &RecipeRouter{
data: data,
}
}
func (rr *RecipeRouter) Route(r *chi.Mux) {
r.Route("/recipes", func(r chi.Router) {
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
json.NewEncoder(w).Encode(rr.data.GetRecipe())
})
})
}