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