-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: middleware as atomic files + docs #222
base: main
Are you sure you want to change the base?
Conversation
so middleware stays maintainable when adding more (like the upcoming file proxy middleware) and has a structure suitable to add tests/ to.
Deploying head-start with Cloudflare Pages
|
@@ -2,6 +2,10 @@ | |||
|
|||
**Head Start leverages [Astro file-based routing](https://docs.astro.build/en/core-concepts/routing/#_top) combined with Cloudflare features for redirects and page not found behaviour. The setup is enhanced with i18n routing, API routing, nested page routing and helpers to resolve routes.** | |||
|
|||
## Routing middleware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add middleware/
to project-structure.md?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, mentioned @sjoerdbeentjes for adding a caveat do the docs, but I feel it is not strictly necessary.
import { preview } from './preview'; | ||
import { redirects } from './redirects'; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,3 @@ | |||
# Middleware | |||
|
|||
**[Astro supports middleware](https://docs.astro.build/en/guides/middleware/) that allows you to intercept requests and responses and inject behaviors dynamically every time a page or endpoint is about to be rendered.** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjoerdbeentjes you recently mentioned the caveat that when home resolves as a static file, middleware will not run. Perhaps it is wise to explicitly add this here.
l# Changes
Refactors middleware to atomic files (
src/middleware/...
), so middleware stays maintainable when adding more (like the upcoming file proxy middleware) and has a structure suitable to add tests to (insrc/middleware/tests/
like done insrc/lib/datocms/tests/
).Associated issue
N/A
How to test
i18n
,redirects
) still work (preview
can't be tested on deploy preview, unless we list it as a preview branch;datocms
is hard to check on deploy preview)datocms
,i18n
,preview
,redirects
) still workChecklist
I have added a decision log entry if the change affects the architecture or changes a significant technology