Init repo

This commit is contained in:
Curt Spark 2025-05-05 20:25:48 +01:00
commit 1b88c3cfac
2 changed files with 38 additions and 0 deletions

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module timefu.li/backend
go 1.24.2

35
main.go Normal file
View File

@ -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)
}