53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
from datetime import datetime, time, timedelta
|
|
from fastapi import APIRouter, Depends, Header, HTTPException, status
|
|
from pydantic import BaseModel, EmailStr, Field
|
|
from typing import Dict, List, Optional, Set, Union
|
|
|
|
|
|
#router = APIRouter()
|
|
|
|
#import app
|
|
|
|
async def get_token_header(x_token: str = Header(...)):
|
|
if x_token != 'fake-super-secret-token':
|
|
raise HTTPException(status_code=400, detail='X-Token header invalid')
|
|
|
|
|
|
async def get_account_header(x_account_id: str = Header(...)):
|
|
print('get_account_header(): '+x_account_id)
|
|
return x_account_id
|
|
|
|
|
|
#Add the processing time to the response header.
|
|
#@app.middleware('http')
|
|
#async def add_process_time_header(request: Request, call_next):
|
|
#import time
|
|
#start_time = time.time()
|
|
#response = await call_next(request)
|
|
#process_time = time.time() - start_time
|
|
#response.headers['X-Process-Time'] = str(process_time)
|
|
#return response
|
|
|
|
|
|
#async def get_token_header(x_token: str = Header(...)):
|
|
#if x_token != 'fake-super-secret-token':
|
|
#raise HTTPException(status_code=400, detail='X-Token header invalid')
|
|
|
|
|
|
#async def get_account_header(x_account_id: str = Header(...)):
|
|
#@app.middleware("http")
|
|
#async def get_account_header(x_account_id: str = Header(...)):
|
|
#return x_account_id
|
|
#x_account_id: str = Header(...)
|
|
#x_account_id = 'static random ID...'
|
|
#response = await call_next(request)
|
|
|
|
#print(x_account_id)
|
|
|
|
#return x_account_id
|
|
|
|
|
|
#async def get_account_header(x_account_id: str = Header(...)):
|
|
#print('get_account_header(): '+x_account_id+'z9999z')
|
|
#return x_account_id+'z9999z'
|