Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func Authentication(c *gin.Context) {
requestUrl := fmt.Sprintf("%s/%s", serviceconfig.GetConfig().ApiRootUrl, "auth/session")
request, err := http.NewRequest("GET", requestUrl, nil)
if err != nil {
log.Printf("[AUTH] Failed to contacft auth service at %s: %v", requestUrl, err)
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error in the log message: "contacft" should be "contact".

Suggested change
log.Printf("[AUTH] Failed to contacft auth service at %s: %v", requestUrl, err)
log.Printf("[AUTH] Failed to contact auth service at %s: %v", requestUrl, err)

Copilot uses AI. Check for mistakes.
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to create request"})
return
}
Expand All @@ -38,19 +39,22 @@ func Authentication(c *gin.Context) {
client := &http.Client{}
response, err := client.Do(request)
if err != nil || response.StatusCode != http.StatusOK {
log.Printf("[AUTH] Failed to validate session with auth service at %s: %v", requestUrl, err)
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
return
}

defer response.Body.Close()
body, err := io.ReadAll(response.Body)
if err != nil {
log.Printf("[AUTH] Failed to read response from auth service at %s: %v", requestUrl, err)
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to read response body"})
return
}

var authResp authServiceResponse
if err := json.Unmarshal(body, &authResp); err != nil {
log.Printf("[AUTH] Failed to parse response from auth service at %s: %v", requestUrl, err)
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to parse response"})
return
}
Expand Down
Loading