diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-09 14:46:52 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-09 14:46:52 +0100 |
commit | d12afb8a151b470552d01b4002839f34cc698c5e (patch) | |
tree | 5f669ffc56af3464e0a2e0f9015f6482bf55afda | |
download | guichet-d12afb8a151b470552d01b4002839f34cc698c5e.tar.gz guichet-d12afb8a151b470552d01b4002839f34cc698c5e.zip |
First commit
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | go.mod | 5 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | main.go | 30 |
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 @@ -0,0 +1,5 @@ +module deuxfleurs.fr/Deuxfleurs/guichet + +go 1.13 + +require github.com/gorilla/sessions v1.2.0 @@ -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= @@ -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) + } +} |