Skip to content

Commit

Permalink
refactor(workers): restful get
Browse files Browse the repository at this point in the history
  • Loading branch information
shaokeyibb committed Jul 17, 2024
1 parent 96071e9 commit 2184a24
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cloudflare-workers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ router.post('/comment', async (req, env, ctx) => {
} satisfies ResponseBody;
});

router.get('/comment', async (req, env, ctx) => {
const query = req.query as GetCommentBody;
router.get('/comment/:path', async (req, env, ctx) => {
const params = req.params as GetCommentBody;

if (query == undefined || query.path == undefined) {
if (params == undefined || params.path == undefined) {
return error(400, 'Invalid request body');
}

const rst = await getComment(env, query);
params.path = decodeURIComponent(params.path);

const rst = await getComment(env, params);

return {
status: 200,
Expand Down

0 comments on commit 2184a24

Please sign in to comment.