Remove session id log, move DiscordGoLogger, add redis

This commit is contained in:
2023-12-24 20:51:30 -06:00
parent e03b8e2d99
commit 5d8130c3a4
5 changed files with 85 additions and 62 deletions

25
api.go
View File

@@ -11,14 +11,9 @@ import (
)
var (
sessionID string
sessionID string = RandomString(5) + Nonce()
)
func init() {
sessionID = RandomString(5) + Nonce()
log.Debug().Str("sessionId", sessionID).Msg("Session ID Generated")
}
type Term struct {
}
@@ -40,7 +35,7 @@ func GetTerms(search string, offset int, max int) ([]Term, error) {
// _body, _ := io.ReadAll(res.Body)
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -67,7 +62,7 @@ func GetPartOfTerms(search string, term int, offset int, max int) ([]TermParts,
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -95,7 +90,7 @@ func GetInstructor(search string, term int, offset int, max int) []Instructor {
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -119,7 +114,7 @@ func GetClassDetails(term int, crn int) *ClassDetails {
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -149,7 +144,7 @@ func Search(subject string, keyword string, term string, startDate time.Time, en
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -177,7 +172,7 @@ func GetSubjects(search string, term int, offset int, max int) []Subject {
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -205,7 +200,7 @@ func GetCampuses(search string, term int, offset int, max int) []Campus {
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -233,7 +228,7 @@ func GetInstructionalMethods(search string, term int, offset int, max int) ([]In
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Printf("ERR Response was not JSON: %s", res.Header.Get("Content-Type"))
}
@@ -256,7 +251,7 @@ func GetCourseMeetingTime(term int, crn int) (*MeetingTimeResponse, error) {
}
// Assert that the response is JSON
if !ContainsContentType(res, "application/json") {
if !ContentTypeMatch(res, "application/json") {
log.Fatal().Msgf("Response was not JSON: %s", res.Header.Get("Content-Type"))
}