blob: 415c7bf59abbb5a1ba219b1ed0fed9e9d5730e33 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package main
import (
"embed"
"html/template"
"net/http"
"github.com/ckrinitsin/go-backend/handlers"
"github.com/ckrinitsin/go-backend/models"
"github.com/gin-gonic/gin"
)
//go:embed templates/*
var templatesFS embed.FS
func main() {
r := gin.Default()
models.ConnectDatabase()
tmpl := template.Must(template.ParseFS(templatesFS, "templates/*"))
r.SetHTMLTemplate(tmpl)
r.GET("/health", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"health-check": "passed",
})
})
r.GET("/", shopping_list.LoadElements)
r.POST("/create", shopping_list.CreateEntry)
r.POST("/delete", shopping_list.DeleteEntries)
r.POST("/toggle", shopping_list.ToggleEntry)
r.Run()
}
|