UNPKG

758 BJavaScriptView Raw
1/**
2 * react-router v8.0.0
3 *
4 * Copyright (c) Remix Software Inc.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE.md file in the root directory of this source tree.
8 *
9 * @license MIT
10 */
11import { isDataWithResponseInit, isRedirectStatusCode } from "../router/router.js";
12//#region lib/server-runtime/data.ts
13async function callRouteHandler(handler, args) {
14 let result = await handler({
15 request: args.request,
16 url: args.url,
17 params: args.params,
18 context: args.context,
19 pattern: args.pattern
20 });
21 if (isDataWithResponseInit(result) && result.init && result.init.status && isRedirectStatusCode(result.init.status)) throw new Response(null, result.init);
22 return result;
23}
24//#endregion
25export { callRouteHandler };