aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-03-15 00:48:20 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-03-15 00:48:20 +0300
commit4f867d7cbcb7cd23b9cdfab3422bad9dc4a92415 (patch)
tree68b059f251196a423df62c0376048cb8bcfe3dfd
parent643942f57a6ebb0afb80f9d633b6b51affeee80d (diff)
allow post requests
-rw-r--r--index.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/index.js b/index.js
index d96216e..f1e4903 100644
--- a/index.js
+++ b/index.js
@@ -27,7 +27,7 @@ const app = new Koa();
const router = new Router();
-router.get('/request', async (ctx, next) => {
+async function requestHandler(ctx, next) {
if (!ctx.query.url)
throw new Error('url not specified')
@@ -35,7 +35,7 @@ router.get('/request', async (ctx, next) => {
binary: false,
headers: [],
data: ''
- };
+ }
let responseSet = false
let pageWrapper = null
@@ -107,11 +107,15 @@ router.get('/request', async (ctx, next) => {
pageWrapper.page.close()
await next()
-})
-.get('/cookies', async (ctx, next) => {
- ctx.body = JSON.stringify(await cookiesStorage.get())
- await next()
-});
+}
+
+router
+ .get('/request', requestHandler)
+ .post('/request', requestHandler)
+ .get('/cookies', async (ctx, next) => {
+ ctx.body = JSON.stringify(await cookiesStorage.get())
+ await next()
+ });
(async () => {