I have messages working in my app with messsages getting added and displayed. However, I have one service called from a CustomMiddleware that is failing. I can add a message and display it when the custom middleware executes but not the service it calls
Here is the middleware code that calls the service
getdata = requests.get(serviceUrl, params=request_get_params)
Where the serviceUrl comes from a registry and the params passed are the same params from the original request.
The atomic service called by serviceUrl is /correlator/api/atomicservice1
The atomicservice1 code that is not working…
class service1(APIView):
def get(self, request, format=None): messages.add_message(request, messages.INFO, 'Atomic Service 1 has executed!') print("========================================================") print("=================== atomicservice1 get() ===============") print("========================================================") return Response({"message": "AtomicService1!"})
My guess is that the requests.get() creates a request that contains the params of the original request but the add message is not working because this request object is not carried back to the middleware and on through the flow.
How can I get these atomic services to add messages. Can I serialize the original request, deserialize it and add the message?
Do I need to make the atomic service callable methods instead of URLs so the original request can be passed? I want to keep the URL method so I have loosely coupled atomic services.