From 34c6b7ccb47ceac8b7e33bae9ae1ebdf1a2e5f13 Mon Sep 17 00:00:00 2001 From: "Gustavo L de Mello (Guz)" Date: Mon, 7 Oct 2024 19:12:27 -0300 Subject: [PATCH] feat: test page --- pages/dashboard.templ | 19 ++++++++++++++++--- pages/routes.go | 4 +++- router/router.go | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/pages/dashboard.templ b/pages/dashboard.templ index 285e903..ffffc8c 100644 --- a/pages/dashboard.templ +++ b/pages/dashboard.templ @@ -1,10 +1,23 @@ package pages -type Dashboard struct {} +import ( + "net/http" -func (p *Dashboard) ServeHTTP() { + "forge.capytal.company/capytalcode/project-comicverse/router/rerrors" +) + +type Dashboard struct{} + +func (p *Dashboard) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if err := p.Component().Render(r.Context(), w); err != nil { + rerrors.InternalError(err).ServeHTTP(w, r) + return + } + w.WriteHeader(http.StatusOK) } templ (p *Dashboard) Component() { - +
+

Hello world

+
} diff --git a/pages/routes.go b/pages/routes.go index 63a22b3..142a78b 100644 --- a/pages/routes.go +++ b/pages/routes.go @@ -4,4 +4,6 @@ import ( "forge.capytal.company/capytalcode/project-comicverse/router" ) -var PAGES = []router.Route{} +var PAGES = []router.Route{ + {Pattern: "/dashboard", Handler: &Dashboard{}}, +} diff --git a/router/router.go b/router/router.go index 5f0085c..68bf515 100644 --- a/router/router.go +++ b/router/router.go @@ -18,8 +18,8 @@ type RouterOpts struct { } type Route struct { - pattern string - handler http.Handler + Pattern string + Handler http.Handler } func NewRouter(opts ...RouterOpts) *Router {