mirror of
https://github.com/skidoodle/pastebin
synced 2025-10-14 09:44:48 +02:00
organize
This commit is contained in:
@@ -66,10 +66,14 @@ func (h *HttpHandler) HandleGet(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
Render(view.BinPreviewPage(id, highlighted), w, r)
|
||||
render(view.BinPreviewPage(id, highlighted), w, r)
|
||||
}
|
||||
|
||||
func Render(component templ.Component, w http.ResponseWriter, r *http.Request) {
|
||||
func (h *HttpHandler) HandleHome(w http.ResponseWriter, r *http.Request) {
|
||||
render(view.BinEditorPage(), w, r)
|
||||
}
|
||||
|
||||
func render(component templ.Component, w http.ResponseWriter, r *http.Request) {
|
||||
err := component.Render(r.Context(), w)
|
||||
if err != nil {
|
||||
internal("could not render template", err, w, r)
|
||||
|
||||
5
main.go
5
main.go
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/csehviktor/pastebin/handler"
|
||||
"github.com/csehviktor/pastebin/store"
|
||||
"github.com/csehviktor/pastebin/view"
|
||||
)
|
||||
|
||||
const addr = ":3000"
|
||||
@@ -19,9 +18,7 @@ func main() {
|
||||
mux.HandleFunc("GET /style.css", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "view/style.css")
|
||||
})
|
||||
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
||||
handler.Render(view.BinEditorPage(), w, r)
|
||||
})
|
||||
mux.HandleFunc("GET /", httpHandler.HandleHome)
|
||||
mux.HandleFunc("POST /", httpHandler.HandleSet)
|
||||
mux.HandleFunc("GET /{id}", httpHandler.HandleGet)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user