diff --git a/backend/WebUI/api_charging.go b/backend/WebUI/api_charging.go index e706a80f..ef912872 100644 --- a/backend/WebUI/api_charging.go +++ b/backend/WebUI/api_charging.go @@ -1,7 +1,6 @@ package WebUI import ( - "context" "encoding/json" "fmt" "net/http" @@ -125,7 +124,14 @@ func GetChargingRecord(c *gin.Context) { if amfUris := webuiSelf.GetOamUris(models.NfType_AMF); amfUris != nil { requestUri := fmt.Sprintf("%s/namf-oam/v1/registered-ue-context", amfUris[0]) - res, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, requestUri, nil) + ctx, pd, tokerErr := webui_context.GetSelf().GetTokenCtx(models.ServiceName_NAMF_OAM, models.NfType_AMF) + if tokerErr != nil { + logger.ProcLog.Errorf("GetTokenCtx error: %+v", tokerErr) + c.JSON(http.StatusInternalServerError, pd) + return + } + + res, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil) if err != nil { logger.ProcLog.Error(err) c.JSON(http.StatusInternalServerError, gin.H{}) diff --git a/backend/WebUI/api_verify.go b/backend/WebUI/api_verify.go index 174cee9d..face038e 100644 --- a/backend/WebUI/api_verify.go +++ b/backend/WebUI/api_verify.go @@ -30,16 +30,18 @@ func GetSmfUserPlaneInfo() (interface{}, error) { webuiSelf := webui_context.GetSelf() webuiSelf.UpdateNfProfiles() - ctx, _, err := webuiSelf.GetTokenCtx(models.ServiceName_NSMF_OAM, models.NfType_SMF) - if err != nil { - logger.ConsumerLog.Infof("GetTokenCtx: service %v, err: %+v", models.ServiceName_NSMF_OAM, err) - } - var jsonData interface{} // TODO: support fetching data from multiple SMF if smfUris := webuiSelf.GetOamUris(models.NfType_SMF); smfUris != nil { requestUri := fmt.Sprintf("%s/nsmf-oam/v1/user-plane-info/", smfUris[0]) + + ctx, pd, err := webuiSelf.GetTokenCtx(models.ServiceName_NSMF_OAM, models.NfType_SMF) + if err != nil { + logger.ConsumerLog.Infof("GetTokenCtx: service %v, err: %+v", models.ServiceName_NSMF_OAM, err) + return pd, err + } + req, err_req := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil) if err_req != nil { logger.ProcLog.Error(err_req) diff --git a/backend/WebUI/api_webui.go b/backend/WebUI/api_webui.go index 38496868..77c61c7f 100644 --- a/backend/WebUI/api_webui.go +++ b/backend/WebUI/api_webui.go @@ -1,7 +1,6 @@ package WebUI import ( - "context" "crypto/rand" "crypto/tls" "encoding/json" @@ -1788,7 +1787,14 @@ func GetRegisteredUEContext(c *gin.Context) { requestUri = fmt.Sprintf("%s/namf-oam/v1/registered-ue-context", amfUris[0]) } - req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, requestUri, nil) + ctx, pd, tokerErr := webui_context.GetSelf().GetTokenCtx(models.ServiceName_NAMF_OAM, models.NfType_AMF) + if tokerErr != nil { + logger.ProcLog.Errorf("GetTokenCtx error: %+v", tokerErr) + c.JSON(http.StatusInternalServerError, pd) + return + } + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil) if err != nil { logger.ProcLog.Error(err) c.JSON(http.StatusInternalServerError, gin.H{}) @@ -1845,7 +1851,15 @@ func GetUEPDUSessionInfo(c *gin.Context) { // TODO: support fetching data from multiple SMF if smfUris := webuiSelf.GetOamUris(models.NfType_SMF); smfUris != nil { requestUri := fmt.Sprintf("%s/nsmf-oam/v1/ue-pdu-session-info/%s", smfUris[0], smContextRef) - req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, requestUri, nil) + + ctx, pd, tokerErr := webui_context.GetSelf().GetTokenCtx(models.ServiceName_NSMF_OAM, models.NfType_SMF) + if tokerErr != nil { + logger.ProcLog.Errorf("GetTokenCtx error: %+v", tokerErr) + c.JSON(http.StatusInternalServerError, pd) + return + } + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil) if err != nil { logger.ProcLog.Error(err) c.JSON(http.StatusInternalServerError, gin.H{})