From 1b88c3cfac1074774ac1741ea37ce63e967fcdf1 Mon Sep 17 00:00:00 2001 From: cspark Date: Mon, 5 May 2025 20:25:48 +0100 Subject: [PATCH] Init repo --- go.mod | 3 +++ main.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 go.mod create mode 100644 main.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..cdfb3f0 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module timefu.li/backend + +go 1.24.2 diff --git a/main.go b/main.go new file mode 100644 index 0000000..562b83f --- /dev/null +++ b/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "log" + "net/http" + "os" + "os/signal" + "syscall" + "time" +) + +func main() { + http.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request) { + fmt.Println("Hi, ", r.Header) + }) + + http_server := &http.Server{ + Addr: ":8080", + Handler: nil, + ReadTimeout: 10 * time.Second, + WriteTimeout: 10 * time.Second, + MaxHeaderBytes: 1 << 20, + } + go func() { + log.Fatal(http_server.ListenAndServe()) + }() + fmt.Println("Server started! Listening in on ", http_server.Addr) + + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, os.Interrupt, syscall.SIGTERM) + <-sigs + fmt.Println("Server stopped!") + os.Exit(1) +}