From b0bb22aa9c9f1d5b2e582e58bf20c6856feb87ec Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Sun, 15 Aug 2021 12:29:03 -0300 Subject: go fmt --- session.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'session.go') 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") -- cgit v1.2.3 From ad30def5420185dfbe2107b1ec972bddc975b358 Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Sun, 15 Aug 2021 13:56:12 -0300 Subject: redis config --- session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'session.go') diff --git a/session.go b/session.go index 45bf86c..bb6175d 100644 --- a/session.go +++ b/session.go @@ -12,7 +12,7 @@ import ( var cache redis.Conn func InitCache() { - conn, err := redis.DialURL("redis://localhost") + conn, err := redis.DialURL(GetConfigValue("redis")) if err != nil { panic(err) } -- cgit v1.2.3 From 7b287bf328f1cb3e8a2532829073c575cac82de8 Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Sun, 15 Aug 2021 17:35:05 -0300 Subject: default value argument for GetConfigValue --- session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'session.go') diff --git a/session.go b/session.go index bb6175d..99ab1c2 100644 --- a/session.go +++ b/session.go @@ -12,7 +12,7 @@ import ( var cache redis.Conn func InitCache() { - conn, err := redis.DialURL(GetConfigValue("redis")) + conn, err := redis.DialURL(GetConfigValue("redis", "redis://localhost")) if err != nil { panic(err) } -- cgit v1.2.3