diff --git a/uapi/appapi.py b/uapi/appapi.py index 6b21abc..a3f8b7d 100644 --- a/uapi/appapi.py +++ b/uapi/appapi.py @@ -141,7 +141,8 @@ class UAPI: raise e if uapi.auth_apiname: auth_uapi = await sor_get_uapi(sor, upappid, iuapi.auth_apiname) - + self.uapi = uapi + self.auth_uapi = auth_uapi kinfo = await get_userapikey(sor, upappid, callerid) self.env.update(kinfo) return auth_uapi, uapi @@ -183,6 +184,10 @@ class UAPI: b = b'' async for chunk in self.__call__(upappid, apiname, callerid, params=params): b += chunk + if self.uapi.response: + dic = json.loads(b.decode('utf-8')) + s = self.rendertmpl(self.uapi.response, dic) + b = s.encode('utf-8') return b async def do_auth(self, auth_uapi): @@ -190,6 +195,9 @@ class UAPI: async for chunk in self.stream_resp(auth_uapi): b+= chunk d = json.loads(b.encode('utf-8')) + if auth_uapi.response: + s = self.rendertmpl(auth_uapi.response, d) + d = json.loads(s) self.env.update(d) return