diff options
author | 2023-05-03 17:40:47 +0100 | |
---|---|---|
committer | 2023-05-03 17:40:47 +0100 | |
commit | 831b67cdb8250f93f66e3b171fab024652bf80f2 (patch) | |
tree | f2b32803f20b581985ca29af960cdc03835f8848 /examples/middleware/src/pages/api | |
parent | ad907196cb42f21d9540ae0d77aa742bf7adf030 (diff) | |
download | astro-831b67cdb8250f93f66e3b171fab024652bf80f2.tar.gz astro-831b67cdb8250f93f66e3b171fab024652bf80f2.tar.zst astro-831b67cdb8250f93f66e3b171fab024652bf80f2.zip |
feat(astro): experimental middleware (#6721)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Diffstat (limited to 'examples/middleware/src/pages/api')
-rw-r--r-- | examples/middleware/src/pages/api/login.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/middleware/src/pages/api/login.ts b/examples/middleware/src/pages/api/login.ts new file mode 100644 index 000000000..fa3f7b59b --- /dev/null +++ b/examples/middleware/src/pages/api/login.ts @@ -0,0 +1,18 @@ +import { APIRoute } from 'astro'; + +export const post: APIRoute = async ({ request }) => { + const data = await request.formData(); + const username = data.get('username'); + const password = data.get('password'); + return new Response( + JSON.stringify({ + username, + password, + }), + { + headers: { + 'content-type': 'application/json', + }, + } + ); +}; |