mirror of
https://github.com/imjasonh/gohtmx
synced 2026-07-07 00:23:12 +00:00
use flags
Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
parent
3800004072
commit
188f20f48d
1 changed files with 12 additions and 4 deletions
16
main.go
16
main.go
|
|
@ -1,23 +1,31 @@
|
|||
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("todos.jsonl")
|
||||
application := app.New(*file)
|
||||
|
||||
// Set up routes
|
||||
mux := http.NewServeMux()
|
||||
application.SetupRoutes(mux)
|
||||
|
||||
// Start server
|
||||
port := ":8080"
|
||||
slog.Info("Starting server", "port", port)
|
||||
if err := http.ListenAndServe(port, mux); err != nil {
|
||||
|
||||
slog.Info("Starting server", "port", *port)
|
||||
if err := http.ListenAndServe(":"+*port, mux); err != nil {
|
||||
slog.Error("Server failed to start", "error", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue