summaryrefslogtreecommitdiff
path: root/.changeset/khaki-glasses-raise.md
diff options
context:
space:
mode:
authorGravatar Houston (Bot) <108291165+astrobot-houston@users.noreply.github.com> 2023-11-09 09:49:35 -0800
committerGravatar GitHub <noreply@github.com> 2023-11-09 12:49:35 -0500
commit83c88706848521922ccd9cbdd914b653e47309db (patch)
tree925696d9995f323b1251a32fae0bce200f228005 /.changeset/khaki-glasses-raise.md
parent4ce20b6fc9f6a216e91ca6fa2946ebbff8bba71d (diff)
downloadastro-83c88706848521922ccd9cbdd914b653e47309db.tar.gz
astro-83c88706848521922ccd9cbdd914b653e47309db.tar.zst
astro-83c88706848521922ccd9cbdd914b653e47309db.zip
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat (limited to '.changeset/khaki-glasses-raise.md')
-rw-r--r--.changeset/khaki-glasses-raise.md48
1 files changed, 0 insertions, 48 deletions
diff --git a/.changeset/khaki-glasses-raise.md b/.changeset/khaki-glasses-raise.md
deleted file mode 100644
index 4a0622a42..000000000
--- a/.changeset/khaki-glasses-raise.md
+++ /dev/null
@@ -1,48 +0,0 @@
----
-'astro': minor
----
-
-## Integration Hooks to add Middleware
-
-It's now possible in Astro for an integration to add middleware on behalf of the user. Previously when a third party wanted to provide middleware, the user would need to create a `src/middleware.ts` file themselves. Now, adding third-party middleware is as easy as adding a new integration.
-
-For integration authors, there is a new `addMiddleware` function in the `astro:config:setup` hook. This function allows you to specify a middleware module and the order in which it should be applied:
-
-```js
-// my-package/middleware.js
-import { defineMiddleware } from 'astro:middleware';
-
-export const onRequest = defineMiddleware(async (context, next) => {
- const response = await next();
-
- if(response.headers.get('content-type') === 'text/html') {
- let html = await response.text();
- html = minify(html);
- return new Response(html, {
- status: response.status,
- headers: response.headers
- });
- }
-
- return response;
-});
-```
-
-You can now add your integration's middleware and specify that it runs either before or after the application's own defined middleware (defined in `src/middleware.{js,ts}`)
-
-```js
-// my-package/integration.js
-export function myIntegration() {
- return {
- name: 'my-integration',
- hooks: {
- 'astro:config:setup': ({ addMiddleware }) => {
- addMiddleware({
- entrypoint: 'my-package/middleware',
- order: 'pre'
- });
- }
- }
- };
-}
-```