feat: 后端初始化
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
export const readJson = async <T = unknown>(request: Request): Promise<T> => {
|
||||
const contentType = request.headers.get('content-type') || ''
|
||||
|
||||
if (!contentType.includes('application/json')) {
|
||||
return {} as T
|
||||
}
|
||||
|
||||
return request.json() as Promise<T>
|
||||
}
|
||||
|
||||
export const getBearerToken = (request: Request) => {
|
||||
const authorization = request.headers.get('authorization') || ''
|
||||
const match = authorization.match(/^Bearer\s+(.+)$/i)
|
||||
|
||||
return match?.[1] || ''
|
||||
}
|
||||
Reference in New Issue
Block a user