forked from Deuxfleurs/guichet
First commit
This commit is contained in:
commit
d12afb8a15
5 changed files with 45 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
guichet
|
5
Makefile
Normal file
5
Makefile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
all: guichet
|
||||||
|
|
||||||
|
guichet: main.go
|
||||||
|
go get -v
|
||||||
|
go build -v
|
5
go.mod
Normal file
5
go.mod
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
module deuxfleurs.fr/Deuxfleurs/guichet
|
||||||
|
|
||||||
|
go 1.13
|
||||||
|
|
||||||
|
require github.com/gorilla/sessions v1.2.0
|
4
go.sum
Normal file
4
go.sum
Normal file
|
@ -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=
|
30
main.go
Normal file
30
main.go
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue