From 8289881df3ed51588e2e3d6cf9dcb5787895fad8 Mon Sep 17 00:00:00 2001 From: mario Date: Tue, 13 May 2025 16:49:07 +0700 Subject: [PATCH] edit: rm debug route --- internal/api/routes.go | 51 ------------------------------------------ 1 file changed, 51 deletions(-) diff --git a/internal/api/routes.go b/internal/api/routes.go index f2519d5..86374fc 100644 --- a/internal/api/routes.go +++ b/internal/api/routes.go @@ -1,9 +1,7 @@ package api import ( - "encoding/json" "net/http" - "strings" "time" "devone.aplikasi.web.id/gitea/mario/go-ohif-proxy/config" @@ -132,54 +130,5 @@ func SetupRouter(cfg *config.Config, logger *zap.Logger) http.Handler { }) }) - // * DEBUG PURPOSE ONLY * - r.Get("/debug/token", func(w http.ResponseWriter, r *http.Request) { - authHeader := r.Header.Get("Authorization") - if authHeader == "" { - w.WriteHeader(http.StatusUnauthorized) - json.NewEncoder(w).Encode(map[string]string{ - "error": "No Authorization header provided", - }) - return - } - - bearerToken := strings.Split(authHeader, " ") - if len(bearerToken) != 2 || strings.ToLower(bearerToken[0]) != "bearer" { - w.WriteHeader(http.StatusBadRequest) - json.NewEncoder(w).Encode(map[string]string{ - "error": "Invalid Authorization format", - }) - return - } - - token := bearerToken[1] - claims, err := authService.ValidateToken(token) - if err != nil { - w.WriteHeader(http.StatusUnauthorized) - json.NewEncoder(w).Encode(map[string]string{ - "error": err.Error(), - }) - return - } - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(map[string]interface{}{ - "status": "valid", - "token_type": claims.TokenType, - "user": map[string]string{ - "id": claims.UserID, - "email": claims.Email, - "role": claims.Role, - "name": claims.UserName, - }, - "patient_info": map[string]string{ - "patient_id": claims.PatientID, - "study_iuid": claims.StudyIUIDs[0], - "accession_number": claims.AccessionNumbers[0], - }, - }) - }) - return r }