Skip to content

Commit

Permalink
ok-2-4
Browse files Browse the repository at this point in the history
  • Loading branch information
aigem committed Sep 12, 2024
1 parent 919db3c commit c7e8e0a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/handlers/requestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ export async function handleRequest(request: Request, env: Env, ctx: ExecutionCo
});
}

const response = await handleWebDAV(request, env);

const response = await handleWebDAV(request, env.BUCKET, env.BUCKET_NAME, env); // 传递 env 参数
setCORSHeaders(response, request);
return response;
} catch (error) {
logger.error("Error in request handling:", error);
return new Response("Internal Server Error", { status: 500 });
}
}
}
4 changes: 1 addition & 3 deletions src/handlers/webdavHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import { WebDAVProps, Env } from '../types';
const SUPPORT_METHODS = ["OPTIONS", "PROPFIND", "MKCOL", "GET", "HEAD", "PUT", "COPY", "MOVE", "DELETE"];
const DAV_CLASS = "1, 2";

export async function handleWebDAV(request: Request, env: Env): Promise<Response> {
const bucket = env.BUCKET;
const bucketName = env.BUCKET_NAME;
export async function handleWebDAV(request: Request, bucket: R2Bucket, bucketName: string, env: Env): Promise<Response> {

// 身份验证处理
if (!authenticate(request, env)) {
Expand Down

0 comments on commit c7e8e0a

Please sign in to comment.