summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorEwy~ <ewy0@protonmail.com>2026-03-31 17:18:35 +0200
committerEwy~ <ewy0@protonmail.com>2026-03-31 17:18:35 +0200
commitcf085e93b7abc53b8ecc78c07210384e0ff8d516 (patch)
tree270bc83c7e4d1c468bd7fcc61d2d65d6f447eda6 /main.go
initial commit
Diffstat (limited to 'main.go')
-rw-r--r--main.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..d30f292
--- /dev/null
+++ b/main.go
@@ -0,0 +1,40 @@
+package main
+
+import (
+ "delayed.link/pages"
+ _ "delayed.link/pages"
+ "delayed.link/storage"
+ "delayed.link/storage/sqlite"
+ "github.com/spf13/pflag"
+ "log"
+ "net"
+ "net/http"
+ "os"
+ "os/signal"
+ "syscall"
+)
+
+var (
+ port = pflag.StringP("port", "p", "8080", "port to listen on")
+ host = pflag.StringP("host", "h", "0.0.0.0", "host to listen on")
+)
+
+func main() {
+ pflag.Parse()
+
+ http.HandleFunc("GET /{$}", pages.Land)
+ http.HandleFunc("POST /", pages.Create)
+ http.HandleFunc("GET /l/{id}", pages.Get)
+
+ storage.Current = sqlite.New()
+ defer storage.Current.Close()
+ err := http.ListenAndServe(net.JoinHostPort(*host, *port), http.DefaultServeMux)
+ log.Printf("Started listening on %v:%v\n", *host, *port)
+ ch := make(chan os.Signal, 1)
+ signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
+ <-ch
+ if err != nil {
+ log.Panic(err)
+ }
+
+}