feat: add default GET handler (#2542)
closes https://github.com/denoland/fresh/issues/2530
This commit is contained in:
@@ -284,14 +284,20 @@ export async function fsRoutes<State>(
|
||||
}
|
||||
}
|
||||
|
||||
if (routeMod.component !== null) {
|
||||
components.push(routeMod.component);
|
||||
}
|
||||
|
||||
const handlers = routeMod.handlers;
|
||||
const routePath = routeMod.config?.routeOverride ??
|
||||
pathToPattern(normalized.slice(1));
|
||||
|
||||
if (routeMod.component !== null) {
|
||||
components.push(routeMod.component);
|
||||
const missingGetHandler = handlers !== null &&
|
||||
isHandlerByMethod(handlers) &&
|
||||
!Object.keys(handlers).includes("GET");
|
||||
if (missingGetHandler) {
|
||||
app.get(routePath, renderMiddleware(components, undefined));
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
handlers === null ||
|
||||
(isHandlerByMethod(handlers) && Object.keys(handlers).length === 0)
|
||||
|
||||
Reference in New Issue
Block a user