Skip to content

Commit

Permalink
refactor: update request handling to use context parameter in PagesFu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
AsenHu authored Oct 31, 2024
1 parent b34defa commit 5165496
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions functions/.well-known/matrix/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ interface Client {
};
}

export const onRequestGet: PagesFunction = async ({ request }) => {
const continent: string = (request.cf.continent as string) || 'default';
export const onRequestGet: PagesFunction = async (context: { request: Request }) => {
const continent: string = (context.request.cf.continent as string) || 'default';
let tag: string;
if (continent === 'AS') {
const country = request.cf.country || 'default';
const country = context.request.cf.country || 'default';
if (country === 'CN') {
tag = 'cn';
} else {
Expand Down
6 changes: 3 additions & 3 deletions functions/.well-known/matrix/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ interface Server {
"m.server": string;
}

export const onRequestGet: PagesFunction = async ({ request }) => {
const continent: string = (request.cf.continent as string) || 'default';
export const onRequestGet: PagesFunction = async (context: { request: Request }) => {
const continent: string = (context.request.cf.continent as string) || 'default';
let tag: string;
if (continent === 'AS') {
const country = request.cf.country || 'default';
const country = context.request.cf.country || 'default';
if (country === 'CN') {
tag = 'cn';
} else {
Expand Down

0 comments on commit 5165496

Please sign in to comment.