diff options
author | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-08-15 12:29:03 -0300 |
---|---|---|
committer | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-08-15 12:30:26 -0300 |
commit | b0bb22aa9c9f1d5b2e582e58bf20c6856feb87ec (patch) | |
tree | 1107a5cbfd05f9b696d7ebacce9475f003db7a4c /session.go | |
parent | 149f71db2d6e1b704ff2712393da5276a622d4dd (diff) |
go fmt
Diffstat (limited to 'session.go')
-rw-r--r-- | session.go | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -1,13 +1,12 @@ package main - import ( + "bufio" "fmt" - "net/http" - "bufio" - "os" - "strings" "github.com/gomodule/redigo/redis" + "net/http" + "os" + "strings" ) var cache redis.Conn @@ -20,7 +19,7 @@ func InitCache() { cache = conn } -func CheckSession(w http.ResponseWriter, r *http.Request) (interface{}, error){ +func CheckSession(w http.ResponseWriter, r *http.Request) (interface{}, error) { c, err := r.Cookie("session_token") @@ -29,15 +28,15 @@ func CheckSession(w http.ResponseWriter, r *http.Request) (interface{}, error){ w.WriteHeader(http.StatusUnauthorized) return nil, err } - + w.WriteHeader(http.StatusBadRequest) return nil, err } - + sessionToken := c.Value response, err := cache.Do("GET", sessionToken) - + if err != nil { w.WriteHeader(http.StatusInternalServerError) return nil, err @@ -50,7 +49,7 @@ func CheckSession(w http.ResponseWriter, r *http.Request) (interface{}, error){ return response, nil } -func GetClientKey() string{ +func GetClientKey() string { file, err := os.Open("clientkey") CheckError(err, "could not open client key in file") |