Home / Function/ onRequest() — astro Function Reference

onRequest() — astro Function Reference

Architecture documentation for the onRequest() function in integration-middleware-post.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  560ed484_5183_a5a2_7219_dfea437e2095["onRequest()"]
  bc5c0997_484d_777f_06e4_29f0dad7a6f0["integration-middleware-post.js"]
  560ed484_5183_a5a2_7219_dfea437e2095 -->|defined in| bc5c0997_484d_777f_06e4_29f0dad7a6f0
  style 560ed484_5183_a5a2_7219_dfea437e2095 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/test/fixtures/middleware-no-user-middleware/integration-middleware-post.js lines 3–13

export const onRequest = defineMiddleware((context, next) => {
	if (context.url.pathname === '/post') {
		return new Response(JSON.stringify({ post: 'works' }), {
			headers: {
				'content-type': 'application/json',
			},
		});
	}

	return next();
});

Subdomains

Frequently Asked Questions

What does onRequest() do?
onRequest() is a function in the astro codebase, defined in packages/astro/test/fixtures/middleware-no-user-middleware/integration-middleware-post.js.
Where is onRequest() defined?
onRequest() is defined in packages/astro/test/fixtures/middleware-no-user-middleware/integration-middleware-post.js at line 3.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free