From c811d35fa57c111454854e1676634d8987b29d36 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 15 Sep 2023 06:39:05 -0400 Subject: [PATCH] backend: WIP Signed-off-by: Vincent Batts --- backend/go.mod | 7 +++++++ backend/go.sum | 8 ++++++++ backend/main.go | 30 ++++++++++++++++++++++++++++++ backend/templates/critters.html | 1 + backend/templates/index.html | 31 +++++++++++++++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 backend/go.sum create mode 100644 backend/main.go create mode 100644 backend/templates/critters.html create mode 100644 backend/templates/index.html diff --git a/backend/go.mod b/backend/go.mod index 81efbc0..2bc9be1 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -1,3 +1,10 @@ module git.batts.cloud/vbatts/critter/backend go 1.20 + +require ( + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/gorilla/mux v1.8.0 // indirect + github.com/redis/go-redis/v9 v9.1.0 // indirect +) diff --git a/backend/go.sum b/backend/go.sum new file mode 100644 index 0000000..1998428 --- /dev/null +++ b/backend/go.sum @@ -0,0 +1,8 @@ +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/redis/go-redis/v9 v9.1.0 h1:137FnGdk+EQdCbye1FW+qOEcY5S+SpY9T0NiuqvtfMY= +github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH1cY3lZl4c= diff --git a/backend/main.go b/backend/main.go new file mode 100644 index 0000000..217c047 --- /dev/null +++ b/backend/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "net/http" + "text/template" + + "github.com/gorilla/mux" + "github.com/redis/go-redis/v9" +) + +var ( + client *redis.Client + templates *template.Template +) + +func main() { + client = redis.NewClient(&redis.Options{ + Addr: "localhost:6379", + DB: 0, + }) + templates = template.Must(template.ParseGlob("templates/*.html")) + r := mux.NewRouter() + r.HandleFunc("/", indexHandler).Methods("GET") + http.Handle("/", r) + http.ListenAndServe(":8080", nil) +} + +func indexHandler(w http.ResponseWriter, r *http.Request) { + templates.ExecuteTemplate(w, "index.html", nil) +} diff --git a/backend/templates/critters.html b/backend/templates/critters.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/backend/templates/critters.html @@ -0,0 +1 @@ + diff --git a/backend/templates/index.html b/backend/templates/index.html new file mode 100644 index 0000000..8d52b61 --- /dev/null +++ b/backend/templates/index.html @@ -0,0 +1,31 @@ + + + + + + + + + + booger snatch + + + + + +