diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-04-20 18:08:02 +0200 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-04-20 18:08:02 +0200 |
| commit | ba9fb9dfdf3e845527a0c00fc304cb52ada9c487 (patch) | |
| tree | 344707a36150eaa41f48803c74feec6f07bbfc83 /main.go | |
| parent | 3b4914327abe8774e77b1677cafa64faa0746958 (diff) | |
| download | shopping-list-ba9fb9dfdf3e845527a0c00fc304cb52ada9c487.tar.gz shopping-list-ba9fb9dfdf3e845527a0c00fc304cb52ada9c487.zip | |
add basic template, shopping list website and a health check
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/main.go b/main.go index c98abf0..a08c858 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,30 @@ package main import ( + "embed" + "html/template" "net/http" + "github.com/ckrinitsin/go-backend/handlers" "github.com/gin-gonic/gin" ) +//go:embed templates/* +var templatesFS embed.FS + func main() { r := gin.Default() - r.GET("/ping", func(c *gin.Context) { + + tmpl := template.Must(template.ParseFS(templatesFS, "templates/*")) + r.SetHTMLTemplate(tmpl) + + r.GET("/health", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ - "message": "pong", + "health-check": "passed", }) }) - r.Run("127.0.0.1:8081") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") + + r.GET("/shopping", shopping_list.LoadElements) + + r.Run() } |