aboutsummaryrefslogtreecommitdiff
path: root/session.go
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-08-15 12:29:03 -0300
committerKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-08-15 12:30:26 -0300
commitb0bb22aa9c9f1d5b2e582e58bf20c6856feb87ec (patch)
tree1107a5cbfd05f9b696d7ebacce9475f003db7a4c /session.go
parent149f71db2d6e1b704ff2712393da5276a622d4dd (diff)
go fmt
Diffstat (limited to 'session.go')
-rw-r--r--session.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/session.go b/session.go
index 0867b16..45bf86c 100644
--- a/session.go
+++ b/session.go
@@ -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")