aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile5
-rw-r--r--go.mod5
-rw-r--r--go.sum4
-rw-r--r--main.go30
5 files changed, 45 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..899c8b2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+guichet
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ef3c9f2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+all: guichet
+
+guichet: main.go
+ go get -v
+ go build -v
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..684bdec
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module deuxfleurs.fr/Deuxfleurs/guichet
+
+go 1.13
+
+require github.com/gorilla/sessions v1.2.0
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..f5e9347
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,4 @@
+github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
+github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
+github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ=
+github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..ce280ba
--- /dev/null
+++ b/main.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "os"
+ "log"
+ "net/http"
+ "fmt"
+
+ "github.com/gorilla/sessions"
+)
+
+var store = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))
+
+func handleHome(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprintf(w, "Hello, world!")
+}
+
+func main() {
+ http.HandleFunc("/", handleHome)
+
+ bind_addr := os.Getenv("HTTP_BIND_ADDR")
+ if bind_addr == "" {
+ bind_addr = ":9991"
+ }
+
+ err := http.ListenAndServe(bind_addr, nil)
+ if err != nil {
+ log.Fatal("Cannot start http server: ", err)
+ }
+}