diff --git a/app/lib_general.py b/app/lib_general.py index 5fc4838..6827b21 100644 --- a/app/lib_general.py +++ b/app/lib_general.py @@ -19,19 +19,19 @@ async def get_token_header(x_token:str = Header(...)): # ### BEGIN ### API Lib General ### async get_account_header() ### +# Updated 2021-08-23 async def get_account_header(x_account_id:str = Header(...)): log.setLevel(logging.WARNING) # DEBUG, INFO, WARN, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) if len(x_account_id): - log.info('The x-account-id header has a value.') + log.info(f'The x-account-id header has a value. x-account-id: {x_account_id}') if account_id := redis_lookup_id_random(table_name='account', record_id_random=x_account_id): log.setLevel(logging.DEBUG) log.info('Found the account_id with the account_id_random value: '+x_account_id) account = { 'id': account_id, 'id_random': x_account_id } else: - log.setLevel(logging.DEBUG) - log.info('The x-account-id was invalid and not empty...') + log.warning('The x-account-id Account ID was not found or it was invalid...') #raise HTTPException(status_code=500) raise HTTPException(status_code=400) # or 404? #return False @@ -40,7 +40,6 @@ async def get_account_header(x_account_id:str = Header(...)): account = { 'id': None, 'id_random': None } #account = { 'id': 0, 'id_random': 'abcdef123456' } - return account # ### END ### API Lib General ### async get_account_header() ### diff --git a/app/models/response_models.py b/app/models/response_models.py index ccaab8c..533f064 100644 --- a/app/models/response_models.py +++ b/app/models/response_models.py @@ -13,7 +13,8 @@ from app.models.common_field_schema import base_fields, default_num_bytes # ### BEGIN ### API Response Model ### Resp_Body_Base() ### -# The pydantic BaseModel to help make consistent REST responses - STI 2021-03-05 +# The pydantic BaseModel to help make consistent REST responses. +# Updated 2021-03-05 class Resp_Body_Base(BaseModel): log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -28,7 +29,8 @@ class Resp_Body_Base(BaseModel): # ### BEGIN ### API Response Model ### mk_resp() ### -# The make response function for REST - STI 2021-03-17 +# The method for making responses for REST. Returns a dict, but currently uses Resp_Body_Base inside the function. +# Update 2021-08-23 def mk_resp( data: None|bool|dict|list, dict_to_json: bool = False, @@ -40,7 +42,7 @@ def mk_resp( by_alias: bool = True, exclude_unset: bool = True, response: Response = None - ): + ) -> dict: log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) @@ -110,4 +112,4 @@ def mk_resp( log.debug(resp_body_dict) return resp_body_dict -# ### END ### API Response Model ### mk_resp() ### \ No newline at end of file +# ### END ### API Response Model ### mk_resp() ###