mirror of
https://github.com/ducky-labs/htmx-go-todo.git
synced 2026-02-04 06:31:00 +00:00
Changes
This commit is contained in:
12
main.go
12
main.go
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
@@ -19,12 +18,15 @@ func main() {
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
err = parseTemplates()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
r := chi.NewRouter()
|
||||
r.Use(middleware.Logger)
|
||||
r.Handle("/static/*", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
|
||||
r.Get("/", func(w http.ResponseWriter, _ *http.Request) {
|
||||
tmpl, _ := template.New("").ParseFiles("templates/index.html")
|
||||
tmpl.ExecuteTemplate(w, "Base", nil)
|
||||
})
|
||||
r.Get("/", handleGetTasks)
|
||||
r.Post("/tasks", handleCreateTask)
|
||||
r.Put("/tasks/{id}/toggle", handleToggleTask)
|
||||
http.ListenAndServe("localhost:3000", r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user