1
0
Fork 0
mirror of https://github.com/imjasonh/gohtmx synced 2026-07-07 00:23:12 +00:00
gohtmx/main.go
Jason Hall 188f20f48d use flags
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-09-01 09:30:20 -04:00

31 lines
585 B
Go

package main
import (
"flag"
"gohtmx/internal/app"
"log/slog"
"net/http"
)
var (
file = flag.String("file", "todos.jsonl", "Path to the JSONL file to store todos")
port = flag.String("port", "8080", "Port to run the server on")
)
func main() {
flag.Parse()
// Create the application
application := app.New(*file)
// Set up routes
mux := http.NewServeMux()
application.SetupRoutes(mux)
// Start server
slog.Info("Starting server", "port", *port)
if err := http.ListenAndServe(":"+*port, mux); err != nil {
slog.Error("Server failed to start", "error", err)
}
}