From 7c96e10a9eadd2948066080fcee9e9818069b1be Mon Sep 17 00:00:00 2001 From: Alex Dickens Date: Sun, 28 Jun 2026 20:51:13 +0100 Subject: [PATCH] Initial Setup --- cmd/bedrock/main.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cmd/bedrock/main.go diff --git a/cmd/bedrock/main.go b/cmd/bedrock/main.go new file mode 100644 index 0000000..c0e1477 --- /dev/null +++ b/cmd/bedrock/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "html/template" + "net/http" + + "git.alexdickens.com/Alex/BedrockCMS/web" + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" + "github.com/go-chi/cors" +) + +var tmpl = template.Must(template.ParseFS(web.Templates, "template/*.html")) + +func main() { + r := chi.NewRouter() + r.Use(middleware.Logger) + r.Use(middleware.Recoverer) + + r.Use(cors.Handler(cors.Options{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Authorization", "Content-Type"}, + })) + + r.Get("/healthz", func(w http.ResponseWriter, req *http.Request) { + w.Write([]byte("ok")) + }) + + r.Get("/", func(w http.ResponseWriter, req *http.Request) { + data := map[string]any{"Title": "Bedrock CMS", "Message": "This Is A Message"} + if err := tmpl.ExecuteTemplate(w, "base", data); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + }) + + http.ListenAndServe(":8080", r) +}