mirror of
https://github.com/kevin-DL/gothstarter.git
synced 2026-01-11 18:14:27 +00:00
initial
This commit is contained in:
10
handlers/auth.go
Normal file
10
handlers/auth.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"gothstarter/views/auth"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func HandleLoginIndex(w http.ResponseWriter, r *http.Request) error {
|
||||
return Render(w, r, auth.Login())
|
||||
}
|
||||
10
handlers/home.go
Normal file
10
handlers/home.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"gothstarter/views/home"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func HandleHome(w http.ResponseWriter, r *http.Request) error {
|
||||
return Render(w, r, home.Index())
|
||||
}
|
||||
22
handlers/shared.go
Normal file
22
handlers/shared.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
)
|
||||
|
||||
type HTTPHandler func(w http.ResponseWriter, r *http.Request) error
|
||||
|
||||
func Make(h HTTPHandler) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if err := h(w, r); err != nil {
|
||||
slog.Error("HTTP handler error", "err", err, "path", r.URL.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Render(w http.ResponseWriter, r *http.Request, c templ.Component) error {
|
||||
return c.Render(r.Context(), w)
|
||||
}
|
||||
Reference in New Issue
Block a user