gotodo/main.go

23 lines
679 B
Go

package main
import (
"fmt"
"log"
"net/http"
)
import "snamellit.com/play/todo/internal/webserver"
func main() {
fmt.Println("Starting web server on port 8080")
fs := http.FileServer(http.Dir("./static"))
http.Handle("/static/", http.StripPrefix("/static/", fs))
http.HandleFunc("/", webserver.IndexHandler)
http.HandleFunc("/todos", webserver.TodosHandler)
togglePath := "/toggle-todo/"
http.Handle(togglePath, http.StripPrefix(togglePath, http.HandlerFunc(webserver.ToggleTodoHandler)))
todoPath := "/todo/"
http.Handle(todoPath, http.StripPrefix(todoPath, http.HandlerFunc(webserver.TodoHandler)))
log.Fatal(http.ListenAndServe(":8080", nil))
}