This commit is contained in:
yumoqing 2025-05-06 18:04:16 +08:00
parent 5dfdb4494e
commit 3f5b71457d
2 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,7 @@
from functools import partial
from sqlor.dbpools import DBPools
from appPublic.httpclient import JsonHttpAPI
from appPublic.log import debug, exception,
from ahserver.globalEnv import password_decode
from aiohttp import web
@ -50,17 +51,21 @@ where
if rec.need_auth and self.auth_api is None:
self.auth_api = await self.get_authapi(sor)
if rec.need_auth and self.auth_api is None:
raise Exception(f'{rec.appname} app has not auth api but need')
e = Exception(f'{rec.appname} app has not auth api but need')
exception(f'{e=}, {format_exc()}')
raise e
rec.auth_api = self.auth_api
rec.apikey_orgid = orgid
return recs[0]
return None
def request(self, apiname, ns):
async def request(self, apiname, ns):
orgs = ns.get('orgs')
api = await self.get_apiinfo(orgs, apiname)
if api is None:
raise Exception(f'{self.appid} app has not {apiname} api')
e = Exception(f'{self.appid} app has not {apiname} api')
exception(f'{e=}, {format_exc()}')
raise e
ns1 = self.env.copy()
ns1['apikey'] = api.apikey
ns1['secretkey'] = api.secretkey
@ -76,7 +81,9 @@ where
datatmpl=self.auth_api.data,
resptmpl=self.auth_api.response)
if self.auth_ret is None:
raise Exception(f'{self.appid} app auth error')
e = Exception(f'{self.appid} app auth error')
exception(f'{e=}, {format_exc()}')
raise e
ns1.update(self.auth_ret)
stream_func = None
if api.stream:

View File

@ -1,4 +1,4 @@
from ahserver.serverenv import get_serverenv
from ahserver.serverenv import ServerEnv
from .appapi import AppAPI, AiohttpAppAPI
def load_uapi():