commit d12afb8a151b470552d01b4002839f34cc698c5e Author: Alex Auvolat Date: Sun Feb 9 14:46:52 2020 +0100 First commit 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) + } +}