aboutsummaryrefslogtreecommitdiff
path: root/session.go
diff options
context:
space:
mode:
authorFChannel0 <77419041+FChannel0@users.noreply.github.com>2021-08-17 12:41:20 -0700
committerGitHub <noreply@github.com>2021-08-17 12:41:20 -0700
commit21917eb2ea72fe40d70c2c991e821aace5430c23 (patch)
tree4dd4122a8661231181ead7c00bdc92c3d498589f /session.go
parent149f71db2d6e1b704ff2712393da5276a622d4dd (diff)
parentc8e0fb94bac60679ccebfcdec9cefb32674b2eec (diff)
Merge pull request #51 from KushBlazingJudah/development
go fmt and docker configuration
Diffstat (limited to 'session.go')
-rw-r--r--session.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/session.go b/session.go
index 0867b16..99ab1c2 100644
--- a/session.go
+++ b/session.go
@@ -1,26 +1,25 @@
package main
-
import (
+ "bufio"
"fmt"
- "net/http"
- "bufio"
- "os"
- "strings"
"github.com/gomodule/redigo/redis"
+ "net/http"
+ "os"
+ "strings"
)
var cache redis.Conn
func InitCache() {
- conn, err := redis.DialURL("redis://localhost")
+ conn, err := redis.DialURL(GetConfigValue("redis", "redis://localhost"))
if err != nil {
panic(err)
}
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")